Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Fixes: #14374 Show warning if torrent files are opened in tor private…
Browse files Browse the repository at this point in the history
… tabs
  • Loading branch information
jumde committed Jun 11, 2018
1 parent 7cff811 commit fc2c229
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ streetAddress=Street Address
submit=Submit
tabsSuggestionTitle=Tabs
topSiteSuggestionTitle=Top Site
torrentBlockedInTor=Torrents are not allowed in tor private tabs.
torrentWarningOk=Ok
turnOffNotifications=Turn off notifications
unknownError=Oops, something went wrong.
unmuteTab=Unmute tab
Expand Down
14 changes: 14 additions & 0 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const tor = require('./tor')

let appStore = null

const tabMessageBox = require('./browser/tabMessageBox')
const beforeSendHeadersFilteringFns = []
const beforeRequestFilteringFns = []
const beforeRedirectFilteringFns = []
Expand Down Expand Up @@ -102,6 +103,19 @@ module.exports.registerHeadersReceivedFilteringCB = (filteringFn) => {
function registerForBeforeRequest (session, partition) {
const isPrivate = module.exports.isPrivate(partition)
session.webRequest.onBeforeRequest((details, muonCb) => {
if ((details.url.indexOf(".torrent") > 0 ||
details.url.indexOf("magnet:") > 0) &&
partition === appConfig.tor.partition) {
if (details.tabId) {
tabMessageBox.show(details.tabId, {
message: `${locale.translation('torrentBlockedInTor')}`,
title: 'Brave',
buttons: [locale.translation('torrentWarningOk')]
})
return
}
}

if (process.env.NODE_ENV === 'development') {
let page = appUrlUtil.getGenDir(details.url)
if (page) {
Expand Down
2 changes: 2 additions & 0 deletions app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ var rendererIdentifiers = function () {
'downloadPaused',
'noDownloads',
'torrentDesc',
'torrentBlockedInTor',
'torrentWarningOk',
'multiSelectionBookmarks',
// Caption buttons in titlebar (min/max/close - Windows only)
'windowCaptionButtonMinimize',
Expand Down

0 comments on commit fc2c229

Please sign in to comment.