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: effectiveTDLPlusOne for subdomain of amazonaws.com yields wrong value #51510
Comments
cc @neild |
I also found this issue . publicsuffix.EffectiveTLDPlusOne( "inbound-smtp.us-east-1.amazonaws.com") result : "inbound-smtp.us-east-1.amazonaws.com". not expect "amazonaws.com" |
Hi @rentiansheng, it seems that the publicsuffix database is quite messy regarding those domains. For instance, An update version of the sample code is at: https://go.dev/play/p/McXmywFKGG0 Probably the solution there is either adding Should I close the current issue and open one at the For the context, my current use case is to obtain a company's main domain from some SMTP relay domain name. Please let me now if anyone thinks publicsuffix is not suitable for that. |
@leandrosansilva This is expected behaviour.
Therefore, the eTLD+1 is |
I have another situation with amazonaws.com. While others work: |
Working as expected. The public-suffix list contains the entry |
Great. I think there should be one more function which can bypass such
behaviour for *.amazonaws.com and similar.
Something which can extract real TLD + one.
For me it is not logical that (even if present in public suffix list)
compute-1.amazonaws.com is treated as TLD.
…On Mon, Aug 28, 2023 at 1:17 PM jub0bs ***@***.***> wrote:
@dpanic <https://github.com/dpanic>
Working as expected. The public-suffix list
<https://publicsuffix.org/list/public_suffix_list.dat> contains the entry
*.compute-1.amazonaws.com. Therefore, according to the spec
<https://github.com/publicsuffix/list/wiki/Format>,
ec2-1-1-1-1.compute-1.amazonaws.com is an eTLD. Therefore, you cannot
derive its eTLD+1; you'd need one more label on the left
<https://go.dev/play/p/myPScO6h6W4> for that.
—
Reply to this email directly, view it on GitHub
<#51510 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACUTPM2A2KJU6M3W63MWCDXXR457ANCNFSM5QBMCFBA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@dpanic |
@jub0bs sure, thanks for heads up. Implemented workaround. https://go.dev/play/p/1xKKMF0RzV- // ExtractDomain extracts domain from suffix list
func ExtractDomain(hostname string) (domain string, err error) {
tmp := strings.Split(hostname, ".")
results := make([]string, 0)
for i := 0; i < len(tmp); i++ {
test := strings.Join(tmp[i:], ".")
domain, _ = publicsuffix.EffectiveTLDPlusOne(test)
if domain != "" {
results = append(results, domain)
}
}
sort.Strings(results)
if len(results) > 0 {
domain = results[len(results)-1]
}
if domain == "" {
err = ErrDomainNotExtracted
}
return
} |
@leandrosansilva If you're satisfied with the answers you've got, could you please self-close this issue? Thanks. |
When calling
publicsuffix.EffectiveTLDPlusOne("inbound-smtp.us-east-1.amazonaws.com")
, I'd expect to obtainamazonaws.com
, but instead I obtain the unmodified valueinbound-smtp.us-east-1.amazonaws.com
.Tested version: latest as on
2022-03-06
.Some code reproducing the issue (on playground: https://go.dev/play/p/VAYufCl2LDY):
The result is:
The text was updated successfully, but these errors were encountered: