Repository navigation
fix: normalize only Unicode decimal digits - #505
Merged
Merged
Conversation
Match Java Character.digit(c, 10) in both span and StringBuilder normalization, preventing numeric symbols from expanding beyond the input buffer. Cover non-decimal numerics, Unicode decimal digits and both stack and pooled inputs. Upstream reference: https://github.com/google/libphonenumber/blob/33be5664343676b27761213d8f5500d682568ea7/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L825-L837
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #505 +/- ##
==========================================
- Coverage 87.92% 87.91% -0.02%
==========================================
Files 43 43
Lines 3900 3896 -4
Branches 995 995
==========================================
- Hits 3429 3425 -4
Misses 272 272
Partials 199 199 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wmundev
marked this pull request as ready for review
October 18, 2026 06:39
twcclegg
approved these changes
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NormalizeDigitsOnly("\u0BF1123") throws on modern targets because Tamil hundred expands into three ASCII digits inside an input-sized buffer. Other numeric symbols can also introduce digits that Java excludes.
Use Unicode decimal-digit values in both the span and StringBuilder implementations, matching Java's Character.digit(c, 10). Each accepted character now produces one ASCII digit; non-decimal numeric characters are stripped or retained according to keepNonDigits.
Regression coverage includes Tamil hundred, fractions, Roman numerals, superscripts, circled numbers, and a negative numeric value. It also verifies Arabic-Indic, Devanagari and fullwidth decimal digits, both stack and pooled inputs, and the shared StringBuilder helper.
Upstream behavior: https://github.com/google/libphonenumber/blob/33be5664343676b27761213d8f5500d682568ea7/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L825-L837
Validation: