internal/normalize: harden against possible attacks; optimize registry
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Iaf89cda3c480d6a8371e5f146ee95fcf6a6a6964
This commit is contained in:
parent
b2256183e1
commit
ffb4ab2295
3 changed files with 24 additions and 11 deletions
|
|
@ -89,8 +89,9 @@ func ExtractReferrerDomain(referrer, siteDomain string) string {
|
|||
// - "news.ycombinator.com" -> "ycombinator.com"
|
||||
eTLDPlus1, err := publicsuffix.EffectiveTLDPlusOne(hostname)
|
||||
if err != nil {
|
||||
// If public suffix lookup fails, use hostname as-is
|
||||
return hostname
|
||||
// If public suffix lookup fails (malformed/unknown TLD), return "other"
|
||||
// to prevent unbounded cardinality from malicious referrers
|
||||
return "other"
|
||||
}
|
||||
|
||||
return eTLDPlus1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue