Regression: IP addresses are accepted as DNS names
briansmith opened this issue · comments
IIUC, this regression was caused by ce28aef.
A DNS name that contains only labels that only have digits is not a valid DNS name. For example, "1.2.3.4" is not a valid DNS name; it's an IP address. Previous versions rejected "1.2.3.4" correctly but also rejected "1.2.3.x" incorrectly. The commit mentioned above fixes the latter case, but broke the former case.
This is problematic for code that does something like this
- Try to parse the host component of the URI as a
Name
. If that succeeds, return theName
. - Otherwise, try to parse the host component of the URI as an IP address. If that succeeds, return the IP address.
Inverting the logic so that parsing as an IP address is attempted first works around the issue. However, since DNS names are much more common in URLs than IP addresses, it would be preferable to get things working so that attempting parsing as a DNS name first would work the intended way.
A DNS name that contains only labels that only have digits
Do you have any references?
I think if I have a domain name of 123
and search .some.domain
it should resolve 123.some.domain
successfully. So while I'm willing to fix the issue, I'm in doubt that it's right.
It seems you are right. I explored this a bit here: https://twitter.com/BRIAN_____/status/989314604453904384. Thanks! I'm closing this.