News for hackers. Stuff that matters.
Re:List of All Current TLDs by darnir on Thursday September 10, 2020 @07:49PM (#24437817)
And then also, please don't parse the PSL yourself. Use an existing library[1] for that. The formal algorithm for finding the TLD is more complicated than you realise at first glance.

I would recommend libPSL[2]. It was written by one of the maintainers of GNU Wget and is currently used by both GNU Wget and libcurl.

Disclosure: I was one of the early contributors to libpsl and closely involved in its initial formation.

[1] https://publicsuffix.org/learn/ [2] https://github.com/rockdaboot/libpsl

Re:List of All Current TLDs by CodesInChaos on Friday September 11, 2020 @04:18AM (#24440285)
In what way is it more complicated that one would naively expect? And why?
Re:List of All Current TLDs by exikyut on Friday September 11, 2020 @04:28AM (#24440349)
I'm not sure.

https://github.com/rockdaboot/libpsl/blob/master/src/psl.c is 2K lines, most of it appears to deal with memory management, character twiddling, and processing/conversion.

Maybe the cookie management?

Re:List of All Current TLDs by knome on Friday September 11, 2020 @08:39AM (#24442070)
For one, it appears to handle punycode internally.

Punycode is a method for encoding international unicode into ascii prefixed with XN--. So this will correctly associate cookies for either the unicode term or its punycode ascii equivalent.

As exanples, wikipedia indicates the international domains with the most name registrations as being the russia's "рф", taiwan's "台灣" and china's "中国", which are represented in DNS as "xn--p1ai", "xn--kpry57d", and "xn--fiqs8s", respectively.

The data appears to indicate hosting sites where users can register their own names against a providers domain ( username.example.com ) as well as exceptions to this where the host's own site then uses subdomains ( www.example.com, admin.example.com, cdn.example.com ) and the host's cookies should still be used.

It lists specific tlds, wildcards where appropriate with *, and notes exceptions to wildcarding by prefixing with !.

Certainly far from something that would be impossible to write your own parser for, but getting everything right on your first go would be harder than one might expect, and getting things wrong here would be likely to leak the user's information between various sites.

Re:List of All Current TLDs by sleevi on Friday September 11, 2020 @08:43AM (#24442119)
https://publicsuffix.org/list/ (See the Algorithm)

Is actually hard to implement correctly and interoperably, even among browsers, and there are sharp edge cases along the way (such as holes within domain trees).

The author of the library referenced at least worked with the PSL maintainers and browsers to make sure they were faithfully and correctly implementing things :)

Re:List of All Current TLDs by ficklepickle on Friday September 11, 2020 @01:12PM (#24444913)
Here's one for ya. Legacy third/fourth level domains on ".ca". They were provincial/municipal respectively. Although new issuance was discontinued in 2010, they still exist.

For example, posts from ansuz.sooke.bc.ca have been popular on HN. Sooke is a municipality, BC is a province.

https://en.wikipedia.org/wiki/.ca#Third-level_(provincial)_a...