From 5f232ed737a1a8fa37cda44e47ccd28fb2f1144b Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Tue, 29 May 2018 16:19:08 -0700 Subject: [PATCH] Reintroduce the whitelist for websites linking to flash download page Fixes the #13500 regression --- app/extensions/brave/content/scripts/blockFlash.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/extensions/brave/content/scripts/blockFlash.js b/app/extensions/brave/content/scripts/blockFlash.js index 7180ecd0f4f..8259645182d 100644 --- a/app/extensions/brave/content/scripts/blockFlash.js +++ b/app/extensions/brave/content/scripts/blockFlash.js @@ -4,6 +4,18 @@ const adobeRegex = new RegExp('//(get\\.adobe\\.com/([a-z_-]+/)*flashplayer|www\\.macromedia\\.com/go/getflash|www\\.adobe\\.com/go/getflash|helpx\\.adobe\\.com/flash-player/([a-z_-]+/)*flash-player)', 'i') +const exemptHostRegex = + new RegExp('(\\.adobe\\.com|www\\.google(\\.\\w+){1,2}|^duckduckgo\\.com|^search\\.yahoo\\.com)$') + +function shouldIntercept(location) { + if (!location) + return true; + + const { protocol, hostname, pathname } = location + return ['http:', 'https:'].includes(protocol) && + !exemptHostRegex.test(hostname) && + !['/search', '/search/'].includes(pathname) +} function blockFlashDetection () { const handler = { @@ -36,7 +48,7 @@ if (chrome.contentSettings.flashEnabled == 'allow') { while (!node.href && node.parentNode) node = node.parentNode const href = node.href - if (href && href.match(adobeRegex)) { + if (href && href.match(adobeRegex) && shouldIntercept(window.location)) { e.preventDefault() chrome.ipcRenderer.send('dispatch-action', JSON.stringify([{ actionType: 'app-flash-permission-requested',