Normalize IDN hostnames before DNS resolution to prevent UnknownHostException#608
Conversation
|
@arturobernalg Just a question. Why not having this normalization logic in |
e59415d to
3726527
Compare
You right. And we avoid duplicated code. |
f900a90 to
4b06d10
Compare
| @Override | ||
| public InetAddress[] resolve(final String host) throws UnknownHostException { | ||
| try { | ||
| final String normalizedHost = IDN.toASCII(host); |
There was a problem hiding this comment.
@arturobernalg I would do IDN.toASCII only if the hostname fails TextUtils#isAllASCII for the sake of optimization.
There was a problem hiding this comment.
@arturobernalg Catching IllegalArgumentException and recovering from it (for instance, by keeping the original hostmame) would be nice here
There was a problem hiding this comment.
@arturobernalg Do you have any objections to doing the test TextUtils#isAllASCII prior to doing IDN.toASCII?
1037377 to
12007d9
Compare
…UnknownHostException during connection.
7fb5b5d to
3c78786
Compare
|
@arturobernalg Please cherry-pick to |
…UnknownHostException during connection. (#608)
Done |
This PR addresses an issue where Unicode hostnames cause UnknownHostException during DNS resolution. The change normalizes hostnames to punycode using IDN.toASCII() before passing them to the DNS resolver.