From 53ef89e17534141a649f7242dff02fba0d6dc62e Mon Sep 17 00:00:00 2001 From: andy brandt Date: Fri, 9 Nov 2018 14:40:46 -0600 Subject: [PATCH] return TOTP regardless of KphOnly option, also prevent it from sending the TOTP secret to the browser --- KeePassNatMsg/Entry/EntrySearch.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/KeePassNatMsg/Entry/EntrySearch.cs b/KeePassNatMsg/Entry/EntrySearch.cs index fef019b..a295cb9 100644 --- a/KeePassNatMsg/Entry/EntrySearch.cs +++ b/KeePassNatMsg/Entry/EntrySearch.cs @@ -255,7 +255,14 @@ private IEnumerable> GetFields(ConfigOpt configOpt, // follow references sfValue = SprEngine.Compile(sfValue, ctx); - if (configOpt.ReturnStringFieldsWithKphOnly) + // KeeOtp support through keepassxc-browser + // KeeOtp stores the TOTP config in a string field "otp" and provides a placeholder "{TOTP}" + // keepassxc-browser needs the value in a string field named "KPH: {TOTP}" + if (sf.Key == "otp") + { + fields.Add(new KeyValuePair("KPH: {TOTP}", SprEngine.Compile("{TOTP}", ctx))); + } + else if (configOpt.ReturnStringFieldsWithKphOnly) { if (sf.Key.StartsWith("KPH: ")) { @@ -268,14 +275,6 @@ private IEnumerable> GetFields(ConfigOpt configOpt, } } - // KeeOtp support through keepassxc-browser - // KeeOtp stores the TOTP config in a string field "otp" and provides a placeholder "{TOTP}" - // keepassxc-browser needs the value in a string field named "KPH: {TOTP}" - if (fields.Exists(p => p.Key == "otp")) - { - fields.Add(new KeyValuePair("KPH: {TOTP}", SprEngine.Compile("{TOTP}", ctx))); - } - if (fields.Count > 0) { var sorted = from e2 in fields orderby e2.Key ascending select e2;