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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp

Issue 2271113002: Accept any string for currency code in PaymentRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow null as per spec Created 4 years, 4 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: third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp b/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
index ca7e0d04fe099047d5b8f7abd15bdf855172977a..6a1fbc0b89a90a6eb8ab097bed0f2dbc50787cda 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
@@ -9,13 +9,16 @@
namespace blink {
+// We limit the maximum length of the currency code to 2048 bytes for security reasons.
+static const int maxCurrencyCodeLength = 2048;
+
bool PaymentsValidators::isValidCurrencyCodeFormat(const String& code, String* optionalErrorMessage)
{
- if (ScriptRegexp("^[A-Z]{3}$", TextCaseSensitive).match(code) == 0)
+ if (code.length() <= maxCurrencyCodeLength)
return true;
if (optionalErrorMessage)
- *optionalErrorMessage = "'" + code + "' is not a valid ISO 4217 currency code, should be 3 upper case letters [A-Z]";
+ *optionalErrorMessage = "The currency code should be at most 2048 characters long";
return false;
}
@@ -26,7 +29,7 @@ bool PaymentsValidators::isValidAmountFormat(const String& amount, String* optio
return true;
if (optionalErrorMessage)
- *optionalErrorMessage = "'" + amount + "' is not a valid ISO 20022 CurrencyAnd30Amount";
+ *optionalErrorMessage = "'" + amount + "' is not a valid amount format";
return false;
}

Powered by Google App Engine
This is Rietveld 408576698