diff options
author | Grace Jia <xiaotonj@google.com> | 2022-03-30 12:20:56 -0700 |
---|---|---|
committer | Grace Jia <xiaotonj@google.com> | 2022-04-05 12:45:13 -0700 |
commit | 16bb0e7854acc5a6821bedc81651cfa579c15b5f (patch) | |
tree | 218fff2d6b52e65c893f789d653f1e631e041f80 /libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java | |
parent | 219fe038593350a7d07bfd60a1e434793e5cd439 (diff) | |
download | libphonenumber-16bb0e7854acc5a6821bedc81651cfa579c15b5f.tar.gz |
Update libphone number to v8.12.46t_frc_odp_330442040t_frc_odp_330442000t_frc_ase_330444010android13-frc-odp-releaseandroid13-dev
Test: CtsTelephonyTestCases:PhoneNumberUtilsTest
Bug: 192062729
Signed-off-by: Grace Jia <xiaotonj@google.com>
Change-Id: I6f16bb69fe9d15fa28acc762956b533d44d75b9d
Diffstat (limited to 'libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java')
-rw-r--r-- | libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java b/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java index c9a1f5c3..be11be57 100644 --- a/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java +++ b/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java @@ -70,10 +70,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("[- ]"); |