-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dns: idna encode hostnames before resolution #25559
Conversation
lib/dns.js
Outdated
@@ -213,6 +215,7 @@ function resolver(bindingName) { | |||
throw new ERR_INVALID_CALLBACK(); | |||
} | |||
|
|||
name = toASCII(name, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function can theoretically throw in
Line 335 in 2c0a751
error('overflow'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk, if so, shouldn't we also handle it here to be lenient whether it uses icu or punycode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url.parse
is synchronous so it's less of an issue. Here the error could only lead to an uncaught exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to ignore exceptions. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of comments. I think the C++ code which does the utf-8 decoding also needs to go, it should assume ASCII, and throw on failure.
@@ -22,6 +22,8 @@ | |||
'use strict'; | |||
|
|||
const cares = internalBinding('cares_wrap'); | |||
const { toASCII } = internalBinding('config').hasIntl ? | |||
internalBinding('icu') : require('punycode'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the policy here, considering punycode
is deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, we do the same thing in lib/url.js
, so it's probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using punycode is the fallback if Node.js is compiled without ICU.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's only deprecated for userland.
@@ -213,6 +215,11 @@ function resolver(bindingName) { | |||
throw new ERR_INVALID_CALLBACK(); | |||
} | |||
|
|||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be needed if we were only using the ICU based toASCII
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is no
Thanks for picking this up @santigimeno ❤️ |
I'm not sure you can remove the |
Isn't there an equivalent that does the job in ASCII instead? |
I don't know, but what's the issue being ASCII a subset of UTF-8? |
@@ -39,7 +39,8 @@ const addresses = { | |||
// An accessible IPv4 DNS server | |||
DNS4_SERVER: '8.8.8.8', | |||
// An accessible IPv4 DNS server | |||
DNS6_SERVER: '2001:4860:4860::8888' | |||
DNS6_SERVER: '2001:4860:4860::8888', | |||
IDNA_HOST: 'españa.icom.museum' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
domaintest.みんな
might be a better testing domain name, info here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 also, I'd say a comment is missing.
@santigimeno Do you have access to node-private? Because this PR is a spiritual duplicate of https://github.com/nodejs-private/node-private/pull/147 :) |
Not really, first time I hear about that repo. Feel free to close this if it's already handled there. |
@santigimeno Sorry for the delay, Santi. I've moved it to #25679. |
Closing in favor of #25679. Thanks for the heads up Ben. |
Fixes: #25558
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes