Compare commits

..

1 Commits

Author SHA1 Message Date
Philipp Crocoll
c934755e1c make settings field for TrayTotp style otp entries optional
closes https://github.com/PhilippC/keepass2android/issues/2458
2024-01-03 08:06:20 +01:00
2 changed files with 10 additions and 19 deletions

View File

@@ -434,7 +434,7 @@ namespace Kp2aAutofillParser
public static List<string> ConvertToCanonicalLowerCaseHints(string[] supportedHints)
{
List<string> result = new List<string>();
foreach (string hint in supportedHints.Where(h => h != null))
foreach (string hint in supportedHints)
{
var canonicalHint = ToCanonicalHint(hint);
result.Add(canonicalHint.ToLower());
@@ -829,7 +829,7 @@ namespace Kp2aAutofillParser
// * if there is no such autofill hint, we use IsPassword to
HashSet<string> autofillHintsOfAllFields = autofillView.InputFields.Where(f => f.AutofillHints != null)
.SelectMany(f => f.AutofillHints).Where(x => x != null).Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet();
.SelectMany(f => f.AutofillHints).Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet();
bool hasLoginAutofillHints = autofillHintsOfAllFields.Intersect(_autofillHintsForLogin).Any();
if (hasLoginAutofillHints)
@@ -839,9 +839,9 @@ namespace Kp2aAutofillParser
string[] viewHints = viewNode.AutofillHints;
if (viewHints == null)
continue;
if (viewHints.Where(h => h != null).Select(AutofillHintsHelper.ToCanonicalHint).Intersect(_autofillHintsForLogin).Any())
if (viewHints.Select(AutofillHintsHelper.ToCanonicalHint).Intersect(_autofillHintsForLogin).Any())
{
AddFieldToHintMap(viewNode, viewHints.Where(h => h != null).Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet().ToArray());
AddFieldToHintMap(viewNode, viewHints.Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet().ToArray());
}
}

View File

@@ -31,17 +31,8 @@ namespace PluginTOTP
_muteWarnings = muteWarnings;
}
/// <summary>
/// Check if specified Entry contains Settings that are not null.
/// </summary>
internal bool SettingsCheck(IDictionary<string, string> entryFields)
{
string settings;
entryFields.TryGetValue(SettingsFieldName, out settings);
return !String.IsNullOrEmpty(settings);
}
internal bool SeedCheck(IDictionary<string, string> entryFields)
internal bool HasSeed(IDictionary<string, string> entryFields)
{
string seed;
entryFields.TryGetValue(SeedFieldName, out seed);
@@ -101,14 +92,14 @@ namespace PluginTOTP
private string[] SettingsGet(IDictionary<string, string> entryFields)
{
return entryFields[SettingsFieldName].Split(';');
return entryFields.TryGetValue(SettingsFieldName, out var settings) ? settings.Split(';') : new[] { "30", "6" };
}
public TotpData GetTotpData(IDictionary<string, string> entryFields)
{
TotpData res = new TotpData();
if (SettingsCheck(entryFields) && SeedCheck(entryFields))
if (HasSeed(entryFields))
{
bool ValidInterval; bool ValidLength; bool ValidUrl;
if (SettingsValidate(entryFields, out ValidInterval, out ValidLength, out ValidUrl))