| Index: components/autofill/core/browser/autofill_data_util.cc
|
| diff --git a/components/autofill/core/browser/autofill_data_util.cc b/components/autofill/core/browser/autofill_data_util.cc
|
| index f55ec9068c50c8a04a02587a1910cff55dea3ced..d7fff0d9e486cec37aa8f6ea20da0641c17f6eb2 100644
|
| --- a/components/autofill/core/browser/autofill_data_util.cc
|
| +++ b/components/autofill/core/browser/autofill_data_util.cc
|
| @@ -14,6 +14,7 @@
|
| #include "components/autofill/core/browser/field_types.h"
|
| #include "components/grit/components_scaled_resources.h"
|
| #include "third_party/icu/source/common/unicode/uscript.h"
|
| +#include "third_party/re2/src/re2/re2.h"
|
|
|
| namespace autofill {
|
| namespace data_util {
|
| @@ -419,5 +420,16 @@ const char* GetCardTypeForBasicCardPaymentType(
|
| return kGenericPaymentRequestData.card_type;
|
| }
|
|
|
| +bool IsValidCountryCode(const std::string& country_code) {
|
| + if (country_code.size() != 2)
|
| + return false;
|
| +
|
| + return re2::RE2::FullMatch(country_code, "^[A-Z]{2}$");
|
| +}
|
| +
|
| +bool IsValidCountryCode(const base::string16& country_code) {
|
| + return IsValidCountryCode(base::UTF16ToUTF8(country_code));
|
| +}
|
| +
|
| } // namespace data_util
|
| } // namespace autofill
|
|
|