Skip to content
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/publicsuffix: EffectiveTLDPlusOne() parses domains incorrectly if there is a trailing dot #11686

Closed
bramp opened this issue Jul 12, 2015 · 4 comments

Comments

@bramp
Copy link

bramp commented Jul 12, 2015

d, _ := publicsuffix.EffectiveTLDPlusOne("foo.bar.golang.org")
fmt.Printf("%s\n", d)

d, _ = publicsuffix.EffectiveTLDPlusOne("foo.bar.golang.org.")
fmt.Printf("%s\n", d)

prints

golang.org
org.

In the 2nd example, the domain has a trailing dot. This is valid, as it indicates this is unambiguous FQDN. I was passing output from DNS records into EffectiveTLDPlusOne when I noticed this issue.

I suggest the EffectiveTLDPlusOne ignores the trailing dot if one exists.

$ go version
go version go1.4.2 darwin/amd64
@ianlancetaylor ianlancetaylor changed the title publicsuffix.EffectiveTLDPlusOne() parses domains incorrectly if there is a trailing dot x/net/publicsuffix: EffectiveTLDPlusOne() parses domains incorrectly if there is a trailing dot Jul 12, 2015
@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Jul 12, 2015
@crawshaw
Copy link
Member

CC @nigeltao

@nigeltao
Copy link
Contributor

FWIW, http://golang.org/pkg/net/http/cookiejar/#PublicSuffixList already says "TODO: specify which of the caller and callee is responsible for... leading and trailing dots". So, yes, it's a known issue. See also #7125. Possibly also related is issue #7122.

@bramp
Copy link
Author

bramp commented Jul 13, 2015

Thanks @crawshaw and @nigeltao. Sorry I didn't find the previous bug, feel free to close this as a DUP of #7125. I will strip the trailing dot myself. I had already been lowercasing the domain, but not doing a great job of canonicalising the domain otherwise.

@nigeltao
Copy link
Contributor

Duplicates #7125.

(No need to apologize).

@golang golang locked and limited conversation to collaborators Jul 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants