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

Side by Side Diff: components/autofill/core/browser/validation.cc

Issue 141843005: rAc: fix some validation issues (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_types.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/validation.h" 5 #include "components/autofill/core/browser/validation.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 iter != text.end(); 121 iter != text.end();
122 ++iter) { 122 ++iter) {
123 if (!IsAsciiDigit(*iter)) 123 if (!IsAsciiDigit(*iter))
124 return false; 124 return false;
125 } 125 }
126 return true; 126 return true;
127 } 127 }
128 128
129 bool IsValidCreditCardSecurityCode(const base::string16& code, 129 bool IsValidCreditCardSecurityCode(const base::string16& code,
130 const base::string16& number) { 130 const base::string16& number) {
131 CreditCard card; 131 std::string type = CreditCard::GetCreditCardType(number);
132 card.SetRawInfo(CREDIT_CARD_NUMBER, number);
133 size_t required_length = 3; 132 size_t required_length = 3;
134 if (card.type() == kAmericanExpressCard) 133 if (type == kAmericanExpressCard)
135 required_length = 4; 134 required_length = 4;
136 135
137 return code.length() == required_length; 136 return code.length() == required_length;
138 } 137 }
139 138
140 bool IsValidEmailAddress(const base::string16& text) { 139 bool IsValidEmailAddress(const base::string16& text) {
141 // E-Mail pattern as defined by the WhatWG. (4.10.7.1.5 E-Mail state) 140 // E-Mail pattern as defined by the WhatWG. (4.10.7.1.5 E-Mail state)
142 const base::string16 kEmailPattern = base::ASCIIToUTF16( 141 const base::string16 kEmailPattern = base::ASCIIToUTF16(
143 "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@" 142 "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@"
144 "[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"); 143 "[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$");
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 number_string.begin() + 9), 210 number_string.begin() + 9),
212 &serial) 211 &serial)
213 || serial == 0) { 212 || serial == 0) {
214 return false; 213 return false;
215 } 214 }
216 215
217 return true; 216 return true;
218 } 217 }
219 218
220 } // namespace autofill 219 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698