Skip to content

Commit

Permalink
Merge pull request #2490 from PhilippC/2488-fix-crash-in-autofill
Browse files Browse the repository at this point in the history
avoid potentiall null hints in autofill (#2488)
  • Loading branch information
PhilippC authored Jan 2, 2024
2 parents aeda304 + f4b5eee commit 8ee13ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Kp2aAutofillParser/AutofillParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public static string[] FilterForSupportedHints(string[] hints)
public static List<string> ConvertToCanonicalLowerCaseHints(string[] supportedHints)
{
List<string> result = new List<string>();
foreach (string hint in supportedHints)
foreach (string hint in supportedHints.Where(h => h != null))
{
var canonicalHint = ToCanonicalHint(hint);
result.Add(canonicalHint.ToLower());
Expand Down Expand Up @@ -829,7 +829,7 @@ protected virtual AutofillTargetId Parse(bool forFill, bool isManualRequest, Aut
// * 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).Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet();
.SelectMany(f => f.AutofillHints).Where(x => x != null).Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet();
bool hasLoginAutofillHints = autofillHintsOfAllFields.Intersect(_autofillHintsForLogin).Any();

if (hasLoginAutofillHints)
Expand All @@ -839,9 +839,9 @@ protected virtual AutofillTargetId Parse(bool forFill, bool isManualRequest, Aut
string[] viewHints = viewNode.AutofillHints;
if (viewHints == null)
continue;
if (viewHints.Select(AutofillHintsHelper.ToCanonicalHint).Intersect(_autofillHintsForLogin).Any())
if (viewHints.Where(h => h != null).Select(AutofillHintsHelper.ToCanonicalHint).Intersect(_autofillHintsForLogin).Any())
{
AddFieldToHintMap(viewNode, viewHints.Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet().ToArray());
AddFieldToHintMap(viewNode, viewHints.Where(h => h != null).Select(AutofillHintsHelper.ToCanonicalHint).ToHashSet().ToArray());
}

}
Expand Down

0 comments on commit 8ee13ac

Please sign in to comment.