Skip to content

Commit

Permalink
Reintroduce the whitelist for websites linking to flash download page
Browse files Browse the repository at this point in the history
Fixes the brave#13500 regression
  • Loading branch information
Slava Kim authored and Slava Kim committed May 29, 2018
1 parent 21f24d0 commit 5f232ed
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/extensions/brave/content/scripts/blockFlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 5f232ed

Please sign in to comment.