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

Unified Diff: components/autofill/core/browser/validation.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/validation.cc
diff --git a/components/autofill/core/browser/validation.cc b/components/autofill/core/browser/validation.cc
index b4c95674ebad46c819e0bbf4881977a180d3d004..060a3724ac050c6245ba5bb2c4c9e60187fc815e 100644
--- a/components/autofill/core/browser/validation.cc
+++ b/components/autofill/core/browser/validation.cc
@@ -127,10 +127,9 @@ bool IsValidCreditCardSecurityCode(const base::string16& code,
bool IsValidEmailAddress(const base::string16& text) {
// E-Mail pattern as defined by the WhatWG. (4.10.7.1.5 E-Mail state)
- const base::string16 kEmailPattern = base::ASCIIToUTF16(
- "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@"
- "[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$");
- return MatchesPattern(text, kEmailPattern);
+ const char kEmailPattern[] =
+ "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$";
+ return MatchesPattern(base::UTF16ToASCII(text), kEmailPattern);
Ilya Sherman 2015/11/19 02:09:00 Please note: UTF16ToASCII is generally unsafe for
}
bool IsValidState(const base::string16& text) {
@@ -139,8 +138,8 @@ bool IsValidState(const base::string16& text) {
}
bool IsValidZip(const base::string16& text) {
- const base::string16 kZipPattern = base::ASCIIToUTF16("^\\d{5}(-\\d{4})?$");
- return MatchesPattern(text, kZipPattern);
+ const char kZipPattern[] = "^\\d{5}(-\\d{4})?$";
+ return MatchesPattern(base::UTF16ToASCII(text), kZipPattern);
}
bool IsSSN(const base::string16& text) {

Powered by Google App Engine
This is Rietveld 408576698