Skip to content

Commit

Permalink
Fix ignoring expired entries on auto-load using local time
Browse files Browse the repository at this point in the history
KeePass2 stores `ExpiryTime` in UTC internally.
  • Loading branch information
bonki committed Dec 19, 2023
1 parent 025f0cf commit c1ecd56
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion KeeAgent/KeeAgentExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ private void MainForm_FileOpened(object sender, FileOpenedEventArgs e)
return;
}

var dtNow = DateTime.UtcNow;
foreach (var entry in e.Database.RootGroup.GetEntries(true)) {
if (e.Database.RecycleBinEnabled) {
var recycleBin = e.Database.RootGroup.FindGroup(e.Database.RecycleBinUuid, true);
Expand All @@ -916,7 +917,7 @@ private void MainForm_FileOpened(object sender, FileOpenedEventArgs e)
}
}

if (entry.Expires && entry.ExpiryTime <= DateTime.Now
if (entry.Expires && entry.ExpiryTime <= dtNow
&& !e.Database.GetKeeAgentSettings().AllowAutoLoadExpiredEntryKey) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion KeeAgent/UI/EntryPickerDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void InitalizeList(bool autodetect)
{
mCustomTreeViewEx.BeginUpdate();
mCustomTreeViewEx.Nodes.Clear();
mCachedNow = DateTime.Now;
mCachedNow = DateTime.UtcNow;
bool entriesFound = false;

foreach (var db in ext.pluginHost.MainWindow.DocumentManager.GetOpenDatabases()) {
Expand Down

0 comments on commit c1ecd56

Please sign in to comment.