diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-07 14:59:17 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-07 14:59:17 +0000 |
commit | 3925de11ddc72bfa751768d1c1ae716a8e7b9a5a (patch) | |
tree | 218fff2d6b52e65c893f789d653f1e631e041f80 /repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java | |
parent | 219fe038593350a7d07bfd60a1e434793e5cd439 (diff) | |
parent | 3590012041750ae2eda6d371c1fab32ea5799f97 (diff) | |
download | libphonenumber-aml_ads_331611190.tar.gz |
Snap for 8418797 from 3590012041750ae2eda6d371c1fab32ea5799f97 to mainline-adservices-releaseaml_ads_331920180aml_ads_331814200aml_ads_331710270aml_ads_331611190aml_ads_331511020aml_ads_331418080aml_ads_331131000android13-mainline-adservices-release
Change-Id: I3e3da6ad0bfcca0fb287fa550703e35b34c23e6c
Diffstat (limited to 'repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java')
-rw-r--r-- | repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java b/repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java index f89a2b81..f41f7e1c 100644 --- a/repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java +++ b/repackaged/libphonenumber/src/com/android/i18n/phonenumbers/AsYouTypeFormatter.java @@ -72,10 +72,12 @@ public class AsYouTypeFormatter { // used by the AYTF. It is eligible when the format element under numberFormat contains groups of // the dollar sign followed by a single digit, separated by valid phone number punctuation. This // prevents invalid punctuation (such as the star sign in Israeli star numbers) getting into the - // output of the AYTF. + // output of the AYTF. We require that the first group is present in the output pattern to ensure + // no data is lost while formatting; when we format as you type, this should always be the case. private static final Pattern ELIGIBLE_FORMAT_PATTERN = Pattern.compile("[" + PhoneNumberUtil.VALID_PUNCTUATION + "]*" - + "(\\$\\d" + "[" + PhoneNumberUtil.VALID_PUNCTUATION + "]*)+"); + + "\\$1" + "[" + PhoneNumberUtil.VALID_PUNCTUATION + "]*(\\$\\d" + + "[" + PhoneNumberUtil.VALID_PUNCTUATION + "]*)*"); // A set of characters that, if found in a national prefix formatting rules, are an indicator to // us that we should separate the national prefix from the number when formatting. private static final Pattern NATIONAL_PREFIX_SEPARATORS_PATTERN = Pattern.compile("[- ]"); |