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

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

Issue 1905143002: Autofill: Check for common angular js prefix when filling exp month. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix code Created 4 years, 8 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 | components/autofill/core/browser/autofill_field_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_field.cc
diff --git a/components/autofill/core/browser/autofill_field.cc b/components/autofill/core/browser/autofill_field.cc
index c9b371305cc05d75be18aef9b74404ebd68da5ee..e6362deabbbaf19d1b95d9f17da72824345ffe33 100644
--- a/components/autofill/core/browser/autofill_field.cc
+++ b/components/autofill/core/browser/autofill_field.cc
@@ -199,12 +199,16 @@ bool FillExpirationMonthSelectControl(const base::string16& value,
if (!StringToInt(value, &month) || month <= 0 || month > 12)
return false;
- // We trim the whitespace from the select values before attempting to convert
- // them to months.
+ // We trim the whitespace and a specific prefix used in AngularJS from the
+ // select values before attempting to convert them to months.
std::vector<base::string16> trimmed_values(field->option_values.size());
- for (size_t i = 0; i < field->option_values.size(); ++i)
+ const base::string16 kNumberPrefix = ASCIIToUTF16("number:");
+ for (size_t i = 0; i < field->option_values.size(); ++i) {
base::TrimWhitespace(field->option_values[i], base::TRIM_ALL,
&trimmed_values[i]);
+ base::ReplaceFirstSubstringAfterOffset(&trimmed_values[i], 0, kNumberPrefix,
+ ASCIIToUTF16(""));
+ }
if (trimmed_values.size() == 12) {
// The select presumable only contains the year's months.
@@ -376,8 +380,7 @@ bool FillSelectControl(const AutofillType& type,
bool FillMonthControl(const base::string16& value, FormFieldData* field) {
// Autofill formats a combined date as month/year.
std::vector<base::string16> pieces = base::SplitString(
- value, base::ASCIIToUTF16("/"),
- base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ value, ASCIIToUTF16("/"), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
if (pieces.size() != 2)
return false;
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_field_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698