diff --git a/app/extensions/brave/locales/en-US/app.properties b/app/extensions/brave/locales/en-US/app.properties index b1fd2773d6e..39da255fdc3 100644 --- a/app/extensions/brave/locales/en-US/app.properties +++ b/app/extensions/brave/locales/en-US/app.properties @@ -238,6 +238,7 @@ submit=Submit tabsSuggestionTitle=Tabs topSiteSuggestionTitle=Top Site urlBlockedInTor=For your privacy, Brave blocks this URL from loading in a private tab when Tor is enabled. +urlBlockedOutsideTor=For your privacy, Brave blocks this URL from loading in a tab without Tor. urlWarningOk=Ok torConnectionError=Unable to connect to the Tor network torConnectionErrorInfo=Brave could not make a connection to the Tor network. Disable Tor to continue private browsing without Tor protection. diff --git a/app/filtering.js b/app/filtering.js index 638c0dab997..939f23e63ff 100644 --- a/app/filtering.js +++ b/app/filtering.js @@ -130,6 +130,14 @@ function registerForBeforeRequest (session, partition) { onBlockedInTor(details, muonCb) return } + } else { + const host = urlParse(details.url).host + // US-ASCII only in `.onion', so no need for locale-dependent + // case-insensitive comparisons. + if (host.toLowerCase().endsWith('.onion')) { + onBlockedOutsideTor(details, muonCb) + return + } } if (process.env.NODE_ENV === 'development') { @@ -406,6 +414,19 @@ function onBlockedInTor (details, muonCb) { } } +function onBlockedOutsideTor (details, muonCb) { + const cb = () => muonCb({cancel: true}) + if (details.tabId && details.resourceType === 'mainFrame') { + tabMessageBox.show(details.tabId, { + message: `${locale.translation('urlBlockedOutsideTor')}`, + title: 'Brave', + buttons: [locale.translation('urlWarningOk')] + }, cb) + } else { + cb() + } +} + /** * Register for notifications for webRequest.onHeadersReceived for a particular * session. diff --git a/app/locale.js b/app/locale.js index 94b33690f42..1ed4f4a1505 100644 --- a/app/locale.js +++ b/app/locale.js @@ -270,6 +270,7 @@ var rendererIdentifiers = function () { 'noDownloads', 'torrentDesc', 'urlBlockedInTor', + 'urlBlockedOutsideTor', 'urlWarningOk', 'multiSelectionBookmarks', // Caption buttons in titlebar (min/max/close - Windows only)