-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
x/net/idna: Display returns invalid label for r4---sn-a5uuxaxjvh-gpm6.googlevideo.com. #27059
Comments
The Display profile attempts to validate labels, and disallows this particular label. The default Profile works since it does not validate. FYI,
I suspect returning an error is typically correct, but then all software using It might be more useful if the default validation ignored non "xn--" R-LDH to prevent software breaking with some of the hostnames used on the internet. It might also help if IDNA is extended in future, but the older software hasn't been rebuilt with support. |
This particular bug is previously described in whatwg/url#53 (comment). To fix this, we could use the same fixes as the WHATWG URL Standard, and set var (
BetterDisplay = idna.New(
idna.MapForLookup(),
idna.StrictDomainName(false),
idna.CheckHyphens(false),
idna.BidiRule(),
)
BetterLookup = idna.New(
idna.MapForLookup(),
idna.StrictDomainName(false),
idna.CheckHyphens(false),
idna.BidiRule(),
idna.Transitional(true),
)
) For good measure, we also set StrictDomainName (STD 3 domain name rules) to false, as it's a restriction not enforced in web browsers. |
Change https://golang.org/cl/317730 mentions this issue: |
EDIT: I was too naive---the STD3 rules can save us from some trouble but not all. However, this is a real concern and I think some protection is better than none. I hope we can keep most STD3 domain name rules intact, possibly an option to whitelist the underscore, but not more. At very least, I will feel very uncomfortable if the
An example would be the URL EDIT: the STD3 check actually could not prevent this attack. A better example would be TL;DR. I hope we do not turn off all STD3 rules in the recommended profiles. |
@mpvl Any thoughts on the above? Thanks. |
@ianlancetaylor But in general, my inclination is to say that if a behavior is in conflict with the specific profile of the specification it is supposed to implement, then it is a bug and the profile should be fixed. If, however, it is a change to a profile because the spec is undesirable (e.g. some WhatWG variant), then this should be a new profile. Maybe this does not result in the best API, but it ensures backwards compatibility for software that relies on the official behavior. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?What did you do?
Transforming domain name to human-readable form with "golang.org/x/net/idna".
What did you expect to see?
I expect to see no error.
What did you see instead?
But
idna.Display
does not agree to accept the host name as a valid one..ToASCII
has the same property.The text was updated successfully, but these errors were encountered: