From e989d6d33dd49eeb07bcf6185d9e3b03ab9a9755 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sun, 7 Nov 2021 19:15:40 +0100 Subject: [PATCH] Better origin exposure recognition --- stolen-data-entry.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/stolen-data-entry.ts b/stolen-data-entry.ts index 804812d..5529c0a 100644 --- a/stolen-data-entry.ts +++ b/stolen-data-entry.ts @@ -2,6 +2,7 @@ import { TCModel } from "@iabtcf/core"; import ExtendedRequest from "./extended-request"; import { getMemory } from "./memory"; import { + getshorthost, isJSONObject, isURL, parseToObject, @@ -127,11 +128,22 @@ export class StolenDataEntry { } private classify(): keyof typeof Classifications { - if (this.value.includes(this.request.originalURL)) { - return "history"; + let result: keyof typeof Classifications; + if ( + [this.value, decodeURIComponent(this.value)].some((haystack) => + [ + this.request.origin, + this.request.originalURL, + getshorthost(this.request.origin), + ].some((needle) => haystack.includes(needle)) + ) + ) { + result = "history"; } else { - return "id"; + result = "id"; } + console.log("classifying", this.value, result, this.request.origin); + return result; } isRelatedToID() {