Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: components/autofill/content/renderer/password_form_conversion_utils.cc

Issue 2874803002: Prevent autofilling credit card security number fields with passwords. (Closed)
Patch Set: Fix build. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/renderer/password_form_conversion_utils.cc
diff --git a/components/autofill/content/renderer/password_form_conversion_utils.cc b/components/autofill/content/renderer/password_form_conversion_utils.cc
index 1a0f3d7ed8f9ecb88bbbe0dff1ecc03cfe364dc1..5d56dc545bee414ea11b71317057401f2708b16b 100644
--- a/components/autofill/content/renderer/password_form_conversion_utils.cc
+++ b/components/autofill/content/renderer/password_form_conversion_utils.cc
@@ -19,6 +19,8 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/content/renderer/form_autofill_util.h"
+#include "components/autofill/core/common/autofill_regex_constants.h"
+#include "components/autofill/core/common/autofill_regexes.h"
#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/password_form.h"
#include "components/autofill/core/common/password_form_field_prediction_map.h"
@@ -429,6 +431,8 @@ bool GetPasswordForm(
if (HasCreditCardAutocompleteAttributes(*input_element))
continue;
+ if (IsCreditCardVerificationPasswordField(*input_element))
+ continue;
bool element_is_invisible = !form_util::IsWebElementVisible(*input_element);
if (input_element->IsTextField()) {
@@ -766,4 +770,15 @@ bool HasCreditCardAutocompleteAttributes(
return false;
}
+bool IsCreditCardVerificationPasswordField(
+ const blink::WebInputElement& field) {
+ if (!field.IsPasswordField())
+ return false;
+
+ static const base::string16 kCardCvcReCached = base::UTF8ToUTF16(kCardCvcRe);
+
+ return MatchesPattern(field.GetAttribute("id").Utf16(), kCardCvcReCached) ||
+ MatchesPattern(field.GetAttribute("name").Utf16(), kCardCvcReCached);
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698