Skip to content

Commit

Permalink
KeePass 2.54 adjustments
Browse files Browse the repository at this point in the history
Fix:
KeePass 2.54 internally changed the way results of searches (Duplicate Paswords, ...) are displayed.
Sensitive data like passwords are now flagged specifically and this resulted in display errors when Global Search returned entries from multiple databases.

Update:
"passwords (and other sensitive data) are now hidden using asterisks by default (if hiding is activated in the main window); the hiding can be toggled using the new '***' button in the toolbar" (KeePass 2.54 release notes)
As the option to show/hide passwords is meanwhile available in KeePass, the previously existing solution of Global Search will be switched off based on the KeePass version.info

Closes #19
  • Loading branch information
Rookiestyle committed Jun 15, 2023
1 parent 79bc7a5 commit fa334d8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace GlobalSearch
{
public static class Util
{
public static readonly Version KeePassVersion_2_54 = new Version(2, 54);
}
public static class Config
{
private static AceCustomConfig CustomConfig = KeePass.Program.Config.CustomConfig;
Expand Down
34 changes: 31 additions & 3 deletions src/GlobalSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private void ListViewFormAdded(ListViewForm f)

private void OnShowListviewForm(object sender, EventArgs e)
{
if (Tools.KeePassVersion == Util.KeePassVersion_2_54) return;
if (Config.PasswordDisplay == Config.PasswordDisplayMode.Always) return;

if (Config.PasswordDisplay == Config.PasswordDisplayMode.EntryviewBased)
Expand Down Expand Up @@ -565,9 +566,9 @@ private void OnClickFindEntry(object sender, EventArgs e)
foreach (Image img in il2.Images)
il.Images.Add(img);

foreach (var o in l)
for (int i = 0; i < l.Count; i++)
{
ListViewItem lvi = o as ListViewItem;
ListViewItem lvi = GetObjectAsListViewItem(l[i]);
if (lvi == null) continue;
ListViewItem.ListViewSubItem lvsi = new ListViewItem.ListViewSubItem();
if (lvi.Tag is PwEntry)
Expand All @@ -587,7 +588,7 @@ private void OnClickFindEntry(object sender, EventArgs e)
PwGroup pg = lvi.Tag as PwGroup;
lvsi.Text = SearchHelp.GetDBName(pg.Entries.GetAt(0));
}
lvi.SubItems.Insert(0, lvsi);
l[i] = AddSubItemToListViewObject(l[i], lvi, lvsi);
}

if ((l.Count == 0) && !string.IsNullOrEmpty(fi.NothingFound))
Expand All @@ -607,6 +608,33 @@ private void OnClickFindEntry(object sender, EventArgs e)
NavigateToSelectedEntry(dlg, false);
}

private object AddSubItemToListViewObject(object o, ListViewItem lvi, ListViewItem.ListViewSubItem lvsi)
{
if (o is ListViewItem)
{
(o as ListViewItem).SubItems.Insert(0, lvsi);
return o;
}
if (Tools.KeePassVersion < Util.KeePassVersion_2_54) return o;
//Could be KeePass 2.54 or higher and type LvfItem
lvi.SubItems.Insert(0, lvsi);
var c = o.GetType().GetConstructor(new Type[] { typeof(ListViewItem) });
if (c != null) o = c.Invoke(new object[] { lvi });
return o;
}

private ListViewItem GetObjectAsListViewItem(object o)
{
ListViewItem lvi = o as ListViewItem;
if (lvi != null) return lvi;
if (Tools.KeePassVersion >= Util.KeePassVersion_2_54)
{
//Could be KeePass 2.54 or higher and type LvfItem
lvi = Tools.GetField("m_lvi", o) as ListViewItem;
}
return lvi;
}

private void NavigateToSelectedEntry(ListViewForm dlg, bool CalledFromSearchForm)
{
PwGroup pg = dlg.ResultGroup as PwGroup; //parent group of selected entry
Expand Down
1 change: 1 addition & 0 deletions src/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private void AdjustNode(TreeNode t, FindInfo fiInfo)

private void SetPwDisplayMode(Config.PasswordDisplayMode m)
{
gPWDisplay.Visible = gPWDisplay.Enabled = Tools.KeePassVersion < Util.KeePassVersion_2_54;
rbPWDisplayAlways.Checked = true;
if (m == Config.PasswordDisplayMode.Never) rbPWDisplayNever.Checked = true;
if (m == Config.PasswordDisplayMode.EntryviewBased) rbPWDisplayEntryList.Checked = true;
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2")]
[assembly: AssemblyFileVersion("1.2")]
[assembly: AssemblyVersion("1.3")]
[assembly: AssemblyFileVersion("1.3")]
2 changes: 1 addition & 1 deletion version.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:
GlobalSearch:1.2
GlobalSearch:1.3
GlobalSearch!de:4
GlobalSearch!pt:3
GlobalSearch!zh:1
Expand Down

0 comments on commit fa334d8

Please sign in to comment.