Index: chrome/browser/autofill/phone_number_i18n.cc |
=================================================================== |
--- chrome/browser/autofill/phone_number_i18n.cc (revision 85791) |
+++ chrome/browser/autofill/phone_number_i18n.cc (working copy) |
@@ -10,14 +10,14 @@ |
#include "base/string_number_conversions.h" |
#include "base/utf_string_conversions.h" |
#include "third_party/libphonenumber/cpp/src/phonenumberutil.h" |
+#include "unicode/locid.h" |
namespace { |
std::string SanitizeLocaleCode(const std::string& locale_code) { |
if (locale_code.length() == 2) |
return locale_code; |
- // Use USA for incomplete locales. |
- return std::string("US"); |
+ return std::string(icu::Locale::getDefault().getCountry()); |
} |
i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat UtilsTypeToPhoneLibType( |
@@ -162,6 +162,12 @@ |
if (validation != i18n::phonenumbers::PhoneNumberUtil::IS_POSSIBLE) |
return false; |
+ // This verifies that number has a valid area code (that in some cases could |
+ // be empty) for parsed country code. Also verifies that this is a valid |
+ // number (in US 1234567 is not valid, because numbers do not start with 1). |
+ if (!phone_util->IsValidNumber(i18n_number)) |
+ return false; |
+ |
std::string formatted_number; |
phone_util->Format(i18n_number, UtilsTypeToPhoneLibType(phone_format), |