Commit graph

8 commits

Author SHA1 Message Date
Shannon Booth
3f7b31fc78 LibURL: Let Host use PublicSuffixData star rule matching
Ever since PublicSuffixData was created, it was using "no star rule"
matching, which is what is needed for the address bar to distinguish
between a domain and a search. URL::Host on the other hand requires
the fallback star rule. Which rule is needed depends on the use case
of the PSL. Support both use cases by a flag in PublicSuffixData.
2026-06-16 06:14:07 +02:00
Shannon Booth
5ef34ecb7a LibURL: Use libpsl for public suffix matching
Replace the generated public suffix table and custom matcher with a
direct LibURL PublicSuffixData implementation backed by libpsl. This
drops our PSL download/generator path and uses the same library already
used by libcurl.

Performance is comparable before and after, while LibURL binary size
is smaller.
2026-06-10 11:43:44 +02:00
Shannon Booth
20bfc49083 LibURL: Preserve trailing dots in public suffix matching
PublicSuffixData handled trailing-dot hosts incorrectly when a PSL rule
matched, causing returned public suffix and registrable-domain results
to drop the trailing dot.

Make PublicSuffixData skip leading dots for matching, ignore a single
trailing dot while running the PSL algorithm, and append that trailing
dot back to returned results.
2026-06-08 20:19:06 +02:00
Shannon Booth
0353cb98bb Tests/LibURL: Consolidate public suffix tests
Having these tests split across two files was annoying to work on.

Move the URL Host public suffix and registrable-domain coverage into
TestPublicSuffix and combine it with the PublicSuffixData coverage in
one table.
2026-06-08 20:19:06 +02:00
Shannon Booth
d21044de15 LibURL: Fix public suffix matching for canonical hosts
Public suffix matching could fail when callers passed host text that
was not already in the same form as the generated PSL table. In
particular, uppercase ASCII hosts like EXAMPLE.COM and UTF-8 IDN hosts
could miss matches even though URL hosts are canonically represented as
lowercase ASCII/IDNA.

Make the PublicSuffixData API difficult to misuse by routing all
invocations through URL::Host overloads so that the canonical hostname
is always what is matched against.
2026-06-08 20:19:06 +02:00
Shannon Booth
ac344a5196 LibURL: Clarify PSL matching API names
Rename PublicSuffixData's raw lookup helpers to make it clear that they
only return public suffixes matched from the PSL data.

This distinguishes them from Host::public_suffix(), which implements the
URL Standard definition and falls back to the top-level domain when no
PSL rule matches.

We need both layers because address bar handling needs the raw lookup to
decide whether input should be treated as a URL or as a search.
2026-06-08 20:19:06 +02:00
Tim Ledbetter
2a5f239d11 LibURL: Reverse host labels before searching the public suffix table
The generated public suffix table stores each entry with it's labels
reversed, but the lookup we were using didn't reverse its input before
searching. This led to multi-label public suffixes not matching when
they should have.
2026-06-07 14:00:48 +02:00
Tim Ledbetter
15518f119c Tests: Add some basic public suffix tests 2025-10-23 15:01:13 +02:00