From f4b5eee17127ae521e7135896618fb9b5319508a Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Tue, 2 Jan 2024 16:26:02 +0100 Subject: [PATCH] avoid potentiall null hints in autofill (#2488) --- src/Kp2aAutofillParser/AutofillParser.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Kp2aAutofillParser/AutofillParser.cs b/src/Kp2aAutofillParser/AutofillParser.cs index fe1cc8233..718cfb5a2 100644 --- a/src/Kp2aAutofillParser/AutofillParser.cs +++ b/src/Kp2aAutofillParser/AutofillParser.cs @@ -434,7 +434,7 @@ public static string[] FilterForSupportedHints(string[] hints) public static List ConvertToCanonicalLowerCaseHints(string[] supportedHints) { List result = new List(); - foreach (string hint in supportedHints) + foreach (string hint in supportedHints.Where(h => h != null)) { var canonicalHint = ToCanonicalHint(hint); result.Add(canonicalHint.ToLower()); @@ -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 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) @@ -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()); } }