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

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

Issue 18927003: [Autofill] Don't validate China UnionPay cards with the Luhn checksum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Parens for order of operations Created 7 years, 5 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 9d561f5126919c75b1568e4abca56ba6fde1f84b..a8aef35f7caafa62f9c31b03c238725922745d03 100644
--- a/components/autofill/core/browser/validation.cc
+++ b/components/autofill/core/browser/validation.cc
@@ -78,11 +78,18 @@ bool IsValidCreditCardNumber(const base::string16& text) {
return false;
if (type == kMasterCard && number.size() != 16)
return false;
+ if (type == kUnionPay && (number.size() < 16 || number.size() > 19))
+ return false;
if (type == kVisaCard && number.size() != 13 && number.size() != 16)
return false;
if (type == kGenericCard && (number.size() < 12 || number.size() > 19))
return false;
+ // Unlike all the other supported types, UnionPay cards lack Luhn checksum
+ // validation.
+ if (type == kUnionPay)
+ return true;
+
// Use the Luhn formula [3] to validate the number.
// [3] http://en.wikipedia.org/wiki/Luhn_algorithm
int sum = 0;
« no previous file with comments | « components/autofill/core/browser/credit_card_unittest.cc ('k') | components/autofill/core/browser/validation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698