noxxi / p5-io-socket-ssl

IO::Socket::SSL Perl Module
36 stars 59 forks source link

PublicSuffix module is unable to distinguish real and phony TLDs #41

Closed FGasper closed 8 years ago

FGasper commented 8 years ago
root@felipe 13:18:30 cpstore_client *
> perl -MIO::Socket::SSL::PublicSuffix -E'say for scalar IO::Socket::SSL::PublicSuffix->default()->public_suffix("q.co.nz")'
co.nz

OK
root@felipe 13:19:07 cpstore_client *
> perl -MIO::Socket::SSL::PublicSuffix -E'say for scalar IO::Socket::SSL::PublicSuffix->default()->public_suffix("q.co.nzzzz")'
nzzzz

^^^ The above seems to indicate that the “TLD” for the 2nd domain is “nzzzz”. There is nothing that a caller can do to distinguish this from the case where “nzzzz” is a real TLD.

This seems like a problem … ? Potentially one causing breakage in IO::Socket::SSL?

noxxi commented 8 years ago

I don't really understand your problem. For any domain which does not have special handling the public suffix the public suffix consists of a single part. For co.nz there is a special handling which means that it will return co.nz as public suffix when asked for q.co.nz. For com or nzzzzzz there is no special handling which means that the public suffix for ebay.com will be com and for q.co.nzzzzzz will be nzzzzzz.

FGasper commented 8 years ago

The desire is to validate TLDs, similar to the tldExists() method in this library:

https://github.com/oncletom/tld.js @noxxi

noxxi commented 8 years ago

You are trying to use PublicSuffix for something it is not intended for. Keeping list of which TLD exist is not the task of the public suffix list. The purpose is not to find out if there is some TLD .nz but if there is a single owner for co.nz or if all the subdomains below co.nz might have a different owner. In fact rule#2 in the algorithm specified in https://publicsuffix.org/list/ says to use * if no rules match, which implicitly means that hostnames with a toplevel not inside the public suffix list are considered to have only a single level of public suffix.