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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java

Issue 2271113002: Accept any string for currency code in PaymentRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed 640847 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: chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
index 9a8eb409f93444fa77323776d246dd071df90d54..1eeaba1465fd253fd6684e46805101464d703676 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
@@ -22,13 +22,12 @@ public class CurrencyStringFormatter {
private static final int DIGITS_AFTER_PERIOD_GROUP = 4;
// Amount currency code pattern.
- private static final String AMOUNT_CURRENCY_CODE_PATTERN = "^[A-Z]{3}$";
+ private static final int MAX_CURRENCY_CODE_LEN = 2048;
// Formatting constants.
private static final int DIGIT_GROUPING_SIZE = 3;
private final Pattern mAmountValuePattern;
- private final Pattern mAmountCurrencyCodePattern;
/**
* The symbol for the currency specified on the bill. For example, the symbol for "USD" is "$".
@@ -59,7 +58,6 @@ public class CurrencyStringFormatter {
assert userLocale != null : "userLocale should not be null";
mAmountValuePattern = Pattern.compile(AMOUNT_VALUE_PATTERN);
- mAmountCurrencyCodePattern = Pattern.compile(AMOUNT_CURRENCY_CODE_PATTERN);
String currencySymbol;
try {
@@ -100,8 +98,7 @@ public class CurrencyStringFormatter {
* @return Whether the currency code is in valid format.
*/
public boolean isValidAmountCurrencyCode(String amountCurrencyCode) {
- return amountCurrencyCode != null
- && mAmountCurrencyCodePattern.matcher(amountCurrencyCode).matches();
+ return amountCurrencyCode != null && amountCurrencyCode.length() <= MAX_CURRENCY_CODE_LEN;
}
/**

Powered by Google App Engine
This is Rietveld 408576698