Improve same-origin test for CNAME-uncloaking purpose

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1062

Related feedback:
- 161a175bb0 (commitcomment-90926455)
This commit is contained in:
Raymond Hill 2022-12-11 11:30:09 -05:00
parent fac6e6e45e
commit c143ded758
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 3 additions and 2 deletions

View File

@ -256,13 +256,14 @@ vAPI.Net = class extends vAPI.Net {
return r; return r;
} }
} }
const isRootDocument = details.type === 'main_frame' &&
this.cnameIgnoreRootDocument;
const hn = hostnameFromNetworkURL(details.url); const hn = hostnameFromNetworkURL(details.url);
const cnRecord = this.cnames.get(hn); const cnRecord = this.cnames.get(hn);
if ( cnRecord !== undefined ) { if ( cnRecord !== undefined ) {
return this.processCanonicalName(hn, cnRecord, details); 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( return browser.dns.resolve(hn, [ 'canonical_name' ]).then(
rec => { rec => {
const cnRecord = this.recordCanonicalName(hn, rec, isRootDocument); const cnRecord = this.recordCanonicalName(hn, rec, isRootDocument);