From c143ded7584d4af739ae410a793d33e087745dcc Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 11 Dec 2022 11:30:09 -0500 Subject: [PATCH] Improve same-origin test for CNAME-uncloaking purpose Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1062 Related feedback: - https://github.com/gorhill/uBlock/commit/161a175bb0596ed6b7734dd7ff77e85204603e96#commitcomment-90926455 --- platform/firefox/vapi-background-ext.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/firefox/vapi-background-ext.js b/platform/firefox/vapi-background-ext.js index b4569f41c..6ec1a0108 100644 --- a/platform/firefox/vapi-background-ext.js +++ b/platform/firefox/vapi-background-ext.js @@ -256,13 +256,14 @@ vAPI.Net = class extends vAPI.Net { return r; } } - const isRootDocument = details.type === 'main_frame' && - this.cnameIgnoreRootDocument; const hn = hostnameFromNetworkURL(details.url); const cnRecord = this.cnames.get(hn); if ( cnRecord !== undefined ) { return this.processCanonicalName(hn, cnRecord, details); } + const documentUrl = details.documentUrl || details.url; + const isRootDocument = this.cnameIgnoreRootDocument && + hn === hostnameFromNetworkURL(documentUrl); return browser.dns.resolve(hn, [ 'canonical_name' ]).then( rec => { const cnRecord = this.recordCanonicalName(hn, rec, isRootDocument);