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

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: 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..f9985756efecd92d3fd0f777c1c57788341d019a 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)
+ 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;

Powered by Google App Engine
This is Rietveld 408576698