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

Unified Diff: chrome/browser/autocomplete_history_manager.cc

Issue 3968001: Update code that previously constructed strings from string iterators only to... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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/browser/autocomplete_history_manager.cc
===================================================================
--- chrome/browser/autocomplete_history_manager.cc (revision 63369)
+++ chrome/browser/autocomplete_history_manager.cc (working copy)
@@ -31,8 +31,6 @@
bool IsSSN(const string16& text) {
string16 number_string;
RemoveChars(text, kSSNSeparators.c_str(), &number_string);
- if (number_string.length() != 9 || !IsStringASCII(number_string))
- return false;
// A SSN is of the form AAA-GG-SSSS (A = area number, G = group number, S =
// serial number). The validation we do here is simply checking if the area,
@@ -42,13 +40,13 @@
// See: http://www.socialsecurity.gov/history/ssn/geocard.html
// http://www.socialsecurity.gov/employer/stateweb.htm
// http://www.socialsecurity.gov/employer/ssnvhighgroup.htm
+ if (number_string.length() != 9 || !IsStringASCII(number_string))
+ return false;
- string16 area_string = number_string.substr(0, 3);
- string16 group_string = number_string.substr(3, 2);
- string16 serial_string = number_string.substr(5, 4);
-
int area;
- if (!base::StringToInt(area_string, &area))
+ if (!base::StringToInt(number_string.begin(),
+ number_string.begin() + 3,
+ &area))
return false;
if (area < 1 ||
area == 666 ||
@@ -57,11 +55,15 @@
return false;
int group;
- if (!base::StringToInt(group_string, &group) || group == 0)
+ if (!base::StringToInt(number_string.begin() + 3,
+ number_string.begin() + 5,
+ &group) || group == 0)
return false;
int serial;
- if (!base::StringToInt(serial_string, &serial) || serial == 0)
+ if (!base::StringToInt(number_string.begin() + 5,
+ number_string.begin() + 9,
+ &serial) || serial == 0)
return false;
return true;

Powered by Google App Engine
This is Rietveld 408576698