nager / Nager.PublicSuffix

.NET public suffix domain parser
MIT License
153 stars 21 forks source link

Wrong behavior #23

Closed OrbintSoft closed 5 years ago

OrbintSoft commented 5 years ago

This library has a bad behavior that doesn't follow any specification, I thought to fix, but it's not a bug, it's bad design. So I explain here how should work, then it's up to you if follow specifications or not.

1) Public Suffix != TLD TLD is only the last part of a public suffix, with the exception of some reserved domains that are not public: -RFC 6761 .example: reserved for use in examples .invalid: reserved for use in obviously invalid domain names .localhost: reserved to avoid conflict with the traditional use of localhost as a hostname test: reserved for use in tests RFC 6762 .local for link-local host names that can be resolved via the Multicast DNS name resolution protocol RFC 7686 .onion for the self-authenticating names of Tor hidden services

But this library assumes the equivalence between public suffix and TLD, so domains like eu-west-2.elasticbeanstalk.com are threated like if they are TLD.

2)If you pass an internal intranet domain or an invalid domain, the library assumes that the last part is a TLD, so you can pass everything and get a nonsense TLD skipping any check

ex: If you pass foo.bar as domain, you get .bar as tld and foo.bar as registrable domain

3) CcSLD are Second level regional domains according to: https://en.wikipedia.org/wiki/Country_code_second-level_domain There is no way to detect a CsSLD since I can't find a public database, but they can be handled as public suffix.

4) https://publicsuffix.org/ it's just an open source database of TLD, CsSLD and other common public domains, used for example for cloud (amazon. google,azuew,...) The database is very useful to check registrable domains, but it's not a reliable source. In any case it can't be used to identify TLDs

5)The database of TLDs is public and handled by ICANN, that provides a reliable source: https://data.iana.org/TLD/tlds-alpha-by-domain.txt

Maybe I'll think to create a new project that follows the specifications. In any case thanks for your hard work, I always appreciate who works for opens source.

tinohager commented 5 years ago

All right, have fun with your new project.