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

Unified Diff: chrome/browser/autocomplete_history_manager.cc

Issue 2853027: Don't save SSNs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 6 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/browser/autocomplete_history_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete_history_manager.cc
===================================================================
--- chrome/browser/autocomplete_history_manager.cc (revision 51464)
+++ chrome/browser/autocomplete_history_manager.cc (working copy)
@@ -24,9 +24,46 @@
// text input element in a form.
const int kMaxAutocompleteMenuItems = 6;
-// The separator characters for credit card values.
-const string16 kCreditCardSeparators = ASCIIToUTF16(" -");
+// The separator characters for SSNs.
+const string16 kSSNSeparators = ASCIIToUTF16(" -");
+bool IsSSN(const string16& text) {
+ string16 number_string;
+ RemoveChars(text, kSSNSeparators.c_str(), &number_string);
+ if (number_string.length() != 9)
+ 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,
+ // group, and serial numbers are valid. It is possible to check if the group
+ // number is valid for the given area, but that data changes all the time.
+ //
+ // See: http://www.socialsecurity.gov/history/ssn/geocard.html
+ // http://www.socialsecurity.gov/employer/stateweb.htm
+ // http://www.socialsecurity.gov/employer/ssnvhighgroup.htm
+
+ 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 = StringToInt(area_string);
+ if (area < 1 ||
+ area == 666 ||
+ area > 733 && area < 750 ||
+ area > 772)
+ return false;
+
+ int group = StringToInt(group_string);
+ if (group == 0)
+ return false;
+
+ int serial = StringToInt(serial_string);
+ if (serial == 0)
+ return false;
+
+ return true;
+}
+
} // namespace
AutocompleteHistoryManager::AutocompleteHistoryManager(
@@ -122,7 +159,8 @@
if (!iter->value().empty() &&
!iter->name().empty() &&
iter->form_control_type() == ASCIIToUTF16("text") &&
- !CreditCard::IsCreditCardNumber(iter->value()))
+ !CreditCard::IsCreditCardNumber(iter->value()) &&
+ !IsSSN(iter->value()))
values.push_back(*iter);
}
« no previous file with comments | « no previous file | chrome/browser/autocomplete_history_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698