From 405b64a7dbf5e3ab4b8a664bcd159cff3f0278f0 Mon Sep 17 00:00:00 2001 From: yan Date: Tue, 12 Dec 2017 00:58:25 +0000 Subject: [PATCH] Don't ignore internal requests in app/filtering and return details.firstPartyUrl as a fallback for main frame URL. Internal requests (tabId == -1) were ignored in order to fix https://github.com/brave/browser-laptop/issues/5934 in https://github.com/brave/browser-laptop/commit/6023abd171eb0ec582eb96e71f18ad30dddba32e. However (1) #5934 works without ignoring internal requests now and (2) generally speaking, non-webview requests should also be protected by HTTPS Everywhere, etc. Test Plan: 1. confirm HTTPS Everywhere and Safebrowsing are working using the test plans in https://github.com/brave/browser-laptop/issues/12253 and https://github.com/brave/browser-laptop/issues/12252 2. confirm that https://github.com/brave/browser-laptop/issues/5934 has not regressed by enabling Pocket --- app/filtering.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/filtering.js b/app/filtering.js index 567f5042d6b..bb097135b3d 100644 --- a/app/filtering.js +++ b/app/filtering.js @@ -674,11 +674,6 @@ module.exports.initPartition = initPartition const filterableProtocols = ['http:', 'https:', 'ws:', 'wss:', 'magnet:', 'file:'] function shouldIgnoreUrl (details) { - // internal requests - if (details.tabId === -1) { - return true - } - // data:, is a special origin from SecurityOrigin::urlWithUniqueSecurityOrigin // and usually occurs when there is an https in an http main frame if (details.firstPartyUrl === 'data:,') { @@ -860,10 +855,10 @@ module.exports.getMainFrameUrl = (details) => { return details.url } const tab = webContents.fromTabID(details.tabId) - if (tab && !tab.isDestroyed()) { + try { return tab.getURL() - } - return null + } catch (ex) {} + return details.firstPartyUrl || null } module.exports.alwaysAllowFullscreen = () => {