From e166b2691c55fa44a153bcad1f4b0f726505014b Mon Sep 17 00:00:00 2001 From: yan Date: Mon, 11 Sep 2017 23:12:35 +0000 Subject: [PATCH] apply brave UA whitelist to first-party subresources fix #10800 Test Plan: load adobe.com within Brave open the developer tools via "option + command + I" select the "Network" tab and reload adobe.com via "command + r" select on the first resource and you'll notice the correct Brave Chrome/60.0.3112.101 UA select another resource that's underneath the first one and is from Host:www.adobe.com the Brave UA should be there --- app/siteHacks.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/siteHacks.js b/app/siteHacks.js index 8ac709a1e4e..5de2315e709 100644 --- a/app/siteHacks.js +++ b/app/siteHacks.js @@ -17,19 +17,20 @@ module.exports.init = () => { } Filtering.registerBeforeSendHeadersFilteringCB((details, isPrivate) => { - if (details.resourceType !== 'mainFrame') { + const mainFrameUrl = Filtering.getMainFrameUrl(details) + if (!mainFrameUrl) { return { resourceName } } - // This filter only applies to top-level requests, so details.url == mainFrameUrl - let domain = urlParse(details.url).hostname.split('.').slice(-2).join('.') - let hack = siteHacks[domain] + const domain = urlParse(mainFrameUrl).hostname.split('.').slice(-2).join('.') + const hack = siteHacks[domain] let customCookie let requestHeaders let cancel - if (hack && hack.onBeforeSendHeaders) { + if (hack && hack.onBeforeSendHeaders && + domain === urlParse(details.url).hostname.split('.').slice(-2).join('.')) { const result = hack.onBeforeSendHeaders.call(this, details) if (result) { customCookie = result.customCookie