Match cookie-database denylist on domain forms

The cookie-database aggregator backstop normalised the agent's
third-party name and looked it up against bare brand keys, but
normalizeAlnum folds the eTLD into the key (cookiedatabase.org ->
cookiedatabaseorg). Domain- and URL-form attributions therefore
slipped past the exact lookup, letting noisy aggregator names be
accepted instead of discarded.

Add uri.DomainLabel to reduce a host-like string to its primary
registrable label and check it alongside the normalised name, so
both brand ("Cookiepedia") and domain forms ("cookiedatabase.org",
"https://www.cookiepedia.co.uk/list") resolve to the same key.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-06-10 09:41:31 +02:00
parent a68c2ef108
commit ae61c20791
4 changed files with 80 additions and 5 deletions

View File

@@ -765,15 +765,25 @@ var cookieDatabaseAggregators = map[string]struct{}{
// nameIsCookieDatabaseAggregator reports whether a candidate vendor name
// is a known cookie-database directory operator that must never be
// attributed a tracker. The comparison is alphanumeric-normalised so
// spacing, punctuation, and casing differences do not matter.
// attributed a tracker. The agent may return either a brand name
// ("Cookiepedia") or a domain form ("cookiedatabase.org"); the latter
// would survive a plain normalised lookup because normalizeAlnum folds
// the eTLD into the key (e.g. "cookiedatabaseorg"). To catch both forms
// the candidate is also reduced to its primary domain label before the
// alphanumeric-normalised lookup. The comparison is alphanumeric-
// normalised so spacing, punctuation, and casing differences do not
// matter.
func nameIsCookieDatabaseAggregator(name string) bool {
normalized := normalizeAlnum(name)
if normalized == "" {
if _, ok := cookieDatabaseAggregators[normalizeAlnum(name)]; ok {
return true
}
label := normalizeAlnum(uri.DomainLabel(name))
if label == "" {
return false
}
_, ok := cookieDatabaseAggregators[normalized]
_, ok := cookieDatabaseAggregators[label]
return ok
}