-
Notifications
You must be signed in to change notification settings - Fork 972
Block loading .onion sites in non-Tor tabs. #14715
Conversation
app/filtering.js
Outdated
@@ -130,6 +130,14 @@ function registerForBeforeRequest (session, partition) { | |||
onBlockedInTor(details, muonCb) | |||
return | |||
} | |||
} else { | |||
const host = urlParse(details.url).host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you probably want the hostname
property not host
since host may include a port number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, thanks. Where is this API documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i find it easiest to just look at what it's mapped to in chromium's GURL in muon brave/common/extensions/url_bindings.cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the API was intended to be consistent with Node's url.parse module
app/filtering.js
Outdated
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')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should check typeof host === 'string' && host.toLowerCase().endsWith('.onion')
since host may be undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UGHHH WHY
app/filtering.js
Outdated
@@ -406,6 +414,19 @@ function onBlockedInTor (details, muonCb) { | |||
} | |||
} | |||
|
|||
function onBlockedOutsideTor (details, muonCb) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] to avoid code duplication, best to refactor this and onBlockedInTor
into a single method that takes an argument indicating why it was blocked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fix #14431 Auditors: @diracdeltas @bsclifton Test Plan: I: 1. Open a tab _without_ Tor (private or nonprivate). 2. Enter: https://nyttips4bmquxfzw.onion/ 3. Confirm that Brave blocks loading the URL. II: 1. Open a tab _without_ Tor (private or nonprivate). 2. Enter: https://nyttips4bmquxfzw.onion:12345/ 3. Confirm that Brave blocks loading the URL. III: 1. Open a private tab with Tor. 2. Enter: https://nyttips4bmquxfzw.onion/ 3. Confirm that the NYT SecureDrop page loads. 4. Bookmark it. 5. Open a tab _without_ Tor (private or nonprivate). 6. Try to load the bookmark. 7. Confirm that Brave blocks loading the bookmark.
855c5a4
to
6efebe7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work
Block loading .onion sites in non-Tor tabs.
Will be re-merged with #15251 |
Merge pull request #14715 from brave/riastradh-tor-blocktorlessonion
fix #14431
Auditors: @diracdeltas @bsclifton
Test Plan:
I:
II:
III:
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
Tests