Skip to content

Fix PSL longest match when a wildcard shares a label with a longer rule - #2750

Merged
remusao merged 1 commit into
masterfrom
fix-psl-longest-match
Nov 12, 2026
Merged

remusao merged 1 commit into
masterfrom
fix-psl-longest-match

Conversation

@remusao

@remusao remusao commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Fix PSL longest match when a wildcard shares a label with a longer rule

With allowPrivateDomains: true, tldts could return a shorter public suffix than the PSL requires.

  • Root cause: the trie lookup prefers an exact edge over *. When the exact label only exists as part of a longer rule (*.futurecms.at next to *.ex.futurecms.at), the *.futurecms.at match was never recorded: ex.futurecms.at → at instead of ex.futurecms.at. 22 hosts in today's list are affected, all in the private section. tldts-icann and tldts-experimental aren't affected.
  • Fix (build time only): exact siblings of * that aren't rules inherit the * rule's flag. The lookup code is unchanged; only the tldts trie data changes (+1 node).
  • Tests: affected hosts in all option modes, builder unit tests, and a PSL check that fails if the list ever adds the one unsupported shape (an exact rule beside a * rule of the other section).

Verified: 0 mismatches against a naive PSL-spec reference over 321k hostnames × 3 option modes. Fuzzing old vs new (10M lookups): every changed result is spec-required. Benchmarks are unchanged (the runtime code is identical).

Reported by @arkark.

@remusao remusao added the PR: Bug Fix 🐛 Increment patch version when merged label Nov 11, 2026
- Root cause: the trie lookup prefers an exact edge over '*'. When the exact
  label only exists as part of a longer rule (e.g. `*.futurecms.at` next to
  `*.ex.futurecms.at`), the walk never records the `*.futurecms.at` match:
  `ex.futurecms.at` got suffix `at` instead of `ex.futurecms.at` (22 hosts,
  private section only).
- Fix (build time only): exact siblings of '*' that aren't rules inherit the
  '*' rule's flag. Lookup code unchanged; only tldts trie data changes.
- Tests: affected hosts in all option modes, builder unit tests, and a PSL
  check for the one unsupported shape (exact rule beside '*' of the other
  section).

Reported-by: arkark (https://github.com/arkark)
@remusao
remusao force-pushed the fix-psl-longest-match branch from 12e413e to 13f8612 Compare November 12, 2026 09:25
@remusao
remusao merged commit 4840552 into master Nov 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 Increment patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant