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

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: 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
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dd8a8a19240febe3460301f8e51924f0896d9be7..0bb0e59edf274bc3539621b135702dbf9c8090a1 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
@@ -21,14 +21,13 @@ public class CurrencyStringFormatter {
private static final int DIGITS_BETWEEN_NEGATIVE_AND_PERIOD_GROUP = 2;
private static final int DIGITS_AFTER_PERIOD_GROUP = 4;
- // Amount currency code pattern.
- private static final String AMOUNT_CURRENCY_CODE_PATTERN = "^[A-Z]{3}$";
+ // Max currency code length. Maximum length of currency code can be at most 2048.
+ 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 "$".
@@ -66,7 +65,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;
int defaultFractionDigits;
@@ -120,8 +118,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;
}
/**
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698