publicsuffix: hold icann-ness until wildcards fully match
Consider the "uberspace.de" domain. The relevant rules in the Public Suffix List are "*.uberspace.de" (in the PRVIATE DOMAIN section) and "de" (in the ICANN DOMAIN section). The PublicSuffix function returns a string and a bool. Both before and after this commit, the string returned is "de", which is correct according to a literal interpretation of the formal algorithm. But the bool returned, icann-ness, is false before and true after. The correct answer is true, since the matching rule, "de", is in the ICANN DOMAIN section of the PSL. Before this commit, the two-stage match for "*.uberspace" set the icann bit when matching the back part, "uberspace", before checking that the front part, the "*" wildcard, also matched. A couple more examples, for the "bd" and "ck" domains. The relevant rules are "*.bd" and "*.ck", with no non-wildcard "bd" or "ck" rule. Before this commit, the PublicSuffix function would return (icann == true), when the correct result is (icann == false), the same as for "nosuchtld". Benchmarks get worse, but correctness trumps performance. Future commits may be able to recover some of the loss. In any case, in absolute terms, 15µs is still pretty fast. name old time/op new time/op delta PublicSuffix-56 11.0µs ± 0% 14.8µs ± 2% +34.57% (p=0.000 n=9+10) Change-Id: I85ca6ab57a31308af5a29c46313197897eab5ab6 Reviewed-on: https://go-review.googlesource.com/c/154977Reviewed-by: Nigel Tao <nigeltao@golang.org>
Showing
This diff is collapsed.
Please
register
or
sign in
to comment