Repository navigation
Conversation
validatePart relies on the final label not starting with a digit to keep IPv4 literals from validating as domain names, but it checked for ASCII 0-9 only. InetAddresses accepts any Unicode decimal digit, so a fullwidth "127.0.0.1" passed both InternetDomainName.isValid and InetAddresses.isInetAddress.
There was a problem hiding this comment.
Code Review
This pull request updates InternetDomainName.java to use Character.isDigit instead of DIGIT_MATCHER.matches when validating the final part of a domain name. This ensures that non-ASCII digits (such as fullwidth or Arabic-Indic digits) are correctly identified, preventing IPv4-like addresses using these characters from being incorrectly validated as domain names. Corresponding unit tests have been added in InternetDomainNameTest.java to verify this behavior. There are no review comments, and I have no additional feedback to provide.
This branch has not been deployed
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.
On master:
validatePartrelies on the final label not starting with a digit to keep IPv4 literals from validating as domain names, but it only checks ASCII 0-9.InetAddressesaccepts any Unicode decimal digit (as its Javadoc notes), so fullwidth or Arabic-Indic forms of an address such as10.0.0.١are accepted by both classes. Code that usesInternetDomainNameto decide that a host is a name rather than an IP literal can be handed an address, and IDNA-aware clients map the fullwidth form back to127.0.0.1.Character.isDigitcovers the same digits thatInetAddressesaccepts. Under GWT it only recognizes ASCII digits, so GWT behavior stays the same and the new test is@GwtIncompatible. Theandroid/copy is left to the mirroring script, as described in CONTRIBUTING.md.