Chromium Code Reviews| 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..e369e2fa8a0e7e940db2ad41fa5a0ed700dd9308 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::ReplaceSubstringsAfterOffset(&trimmed_values[i], 0, kNumberPrefix, |
|
Justin Donnelly
2016/04/21 20:11:10
ReplaceFirstSubstringAfterOffset?
Mathieu
2016/04/22 02:30:37
Oops, thanks!
|
| + ASCIIToUTF16("")); |
| base::TrimWhitespace(field->option_values[i], base::TRIM_ALL, |
| &trimmed_values[i]); |
| + } |
| 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; |