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

Unified Diff: components/autofill/core/browser/validation.cc

Issue 2611863002: Refactors cvc and expiration date validation in CC upload logic as well as unmask prompt. (Closed)
Patch Set: Addressed comments Created 3 years, 11 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/core/browser/validation.cc
diff --git a/components/autofill/core/browser/validation.cc b/components/autofill/core/browser/validation.cc
index b784a2697937f8e9586e1292376ca73cf164481a..15a96e6ab226bfb786a6ed6352523cf53dfc05c4 100644
--- a/components/autofill/core/browser/validation.cc
+++ b/components/autofill/core/browser/validation.cc
@@ -87,25 +87,11 @@ bool IsValidCreditCardNumber(const base::string16& text) {
return (sum % 10) == 0;
}
-bool IsValidCreditCardSecurityCode(const base::string16& text) {
- if (text.size() < 3U || text.size() > 4U)
- return false;
-
- for (const base::char16& it : text) {
- if (!base::IsAsciiDigit(it))
- return false;
- }
- return true;
-}
-
bool IsValidCreditCardSecurityCode(const base::string16& code,
- const base::string16& number) {
- const char* const type = CreditCard::GetCreditCardType(number);
- size_t required_length = 3;
- if (type == kAmericanExpressCard)
- required_length = 4;
-
- return code.length() == required_length;
+ const base::StringPiece card_type) {
+ size_t required_length = card_type == kAmericanExpressCard ? 4 : 3;
+ return code.length() == required_length &&
+ base::ContainsOnlyChars(code, base::ASCIIToUTF16("0123456789"));
}
bool IsValidEmailAddress(const base::string16& text) {
« no previous file with comments | « components/autofill/core/browser/validation.h ('k') | components/autofill/core/browser/validation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698