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

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

Issue 1453193002: autofill: switch autofill_regexes to RE2 library (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: macros.h Created 5 years, 1 month 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/credit_card_field.cc
diff --git a/components/autofill/core/browser/credit_card_field.cc b/components/autofill/core/browser/credit_card_field.cc
index 3b24ec38c1851268949aaa7ce297cda4ded4c9d8..059cb8a67eda7f5e040e6056a015c57120645979 100644
--- a/components/autofill/core/browser/credit_card_field.cc
+++ b/components/autofill/core/browser/credit_card_field.cc
@@ -40,7 +40,8 @@ bool FindConsecutiveStrings(const std::vector<base::string16>& regex_needles,
for (size_t i = 0; i < haystack.size() - regex_needles.size() + 1; ++i) {
for (size_t j = 0; j < regex_needles.size(); ++j) {
- if (!MatchesPattern(haystack[i + j], regex_needles[j]))
+ if (!MatchesPattern(base::UTF16ToASCII(haystack[i + j]),
+ base::UTF16ToASCII(regex_needles[j])))
break;
if (j == regex_needles.size() - 1)
@@ -214,21 +215,22 @@ bool CreditCardField::LikelyCardMonthSelectField(AutofillScanner* scanner) {
return false;
// Filter out years.
- const base::string16 kNumericalYearRe =
- base::ASCIIToUTF16("[1-9][0-9][0-9][0-9]");
+ const char kNumericalYearRe[] = "[1-9][0-9][0-9][0-9]";
for (const auto& value : field->option_values) {
- if (MatchesPattern(value, kNumericalYearRe))
+ if (MatchesPattern(base::UTF16ToASCII(value), kNumericalYearRe))
return false;
}
for (const auto& value : field->option_contents) {
- if (MatchesPattern(value, kNumericalYearRe))
+ if (MatchesPattern(base::UTF16ToASCII(value), kNumericalYearRe))
return false;
}
// Look for numerical months.
- const base::string16 kNumericalMonthRe = base::ASCIIToUTF16("12");
- if (MatchesPattern(field->option_values.back(), kNumericalMonthRe) ||
- MatchesPattern(field->option_contents.back(), kNumericalMonthRe)) {
+ const char kNumericalMonthRe[] = "12";
+ if (MatchesPattern(base::UTF16ToASCII(field->option_values.back()),
+ kNumericalMonthRe) ||
+ MatchesPattern(base::UTF16ToASCII(field->option_contents.back()),
+ kNumericalMonthRe)) {
return true;
}

Powered by Google App Engine
This is Rietveld 408576698