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

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: 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..515f73bb19f884efa2c12ca39ae9f96c3dd1bb65 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 (IsCreditCardVerificationField(*input_element))
+ continue;
bool element_is_invisible = !form_util::IsWebElementVisible(*input_element);
if (input_element->IsTextField()) {
@@ -766,4 +770,14 @@ bool HasCreditCardAutocompleteAttributes(
return false;
}
+bool IsCreditCardVerificationField(const blink::WebInputElement& field) {
Mathieu 2017/05/11 12:54:03 IsCreditCardVerificationAndPasswordField?
pkalinnikov 2017/05/11 14:03:07 I think it looks better without "And". WDYT?
Mathieu 2017/05/11 15:40:08 The logic of this function is "returns true if the
pkalinnikov 2017/05/12 08:42:05 Done in patch#2.
+ if (!field.IsPasswordField())
+ return false;
+
+ static const base::string16 kCardCvcReCached = base::UTF8ToUTF16(kCardCvcRe);
dvadym 2017/05/11 11:46:53 Probably it makes sense to use another regexps for
Mathieu 2017/05/11 12:54:03 We've really only seen this problem with CVC field
dvadym 2017/05/11 14:27:51 I didn't see any other type for password fields. B
Mathieu 2017/05/11 15:40:08 Text fields that would be type=password and contai
dvadym 2017/05/11 15:50:18 I mean type=text, i.e. to expand this function to
+
+ return MatchesPattern(field.GetAttribute("id").Utf16(), kCardCvcReCached) ||
Mathieu 2017/05/11 12:54:04 I'm pretty sure this will cache the patterns, so i
pkalinnikov 2017/05/11 14:03:07 Can you elaborate on what you mean by "this will c
Mathieu 2017/05/11 15:40:08 you can do UTF8ToUTF16(kCardCvcRe), no? That's wha
pkalinnikov 2017/05/12 08:42:05 Well, I do the same. But instead of storing the va
Mathieu 2017/05/12 12:24:44 Can you file a bug for the general behavior you de
pkalinnikov 2017/05/12 14:48:21 Will do.
+ MatchesPattern(field.GetAttribute("name").Utf16(), kCardCvcReCached);
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698