-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix WebTorrent instant streaming playback links #2990
Conversation
2bbc6c9
to
e56ef6a
Compare
components/brave_webtorrent/browser/net/brave_torrent_redirect_network_delegate_helper.cc
Show resolved
Hide resolved
e56ef6a
to
d374114
Compare
non_torrent_url_ = GURL("https://webtorrent.io/torrents/sintel"); | ||
extension_url_ = GURL( |
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 renamed the extension_url_
variable to torrent_extension_url_
so the naming is consistent across all variables.
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.
Code itself LGTM, but CI build failed due to version mismatch, could you rebase & retry?
I would like to see jenkins CI pass before merging this.
d374114
to
238072c
Compare
Sure thing. Looks like I got unlucky and the version just changed :/ |
238072c
to
42c7b8f
Compare
@feross Please help fix lint errors below.
You may run |
42c7b8f
to
e6f061b
Compare
Thanks - didn't realize that there was an |
- `renderFileLink` is never called when `torrent` is null - Remove duplicate props deconstruction
e6f061b
to
f073021
Compare
When the user clicks on a file in the torrent file list, a new tab opens which points to the .torrent file, but with a file fragment appended. For example, the torrent https://webtorrent.io/torrents/big-buck-bunny.torrent would have a link to https://webtorrent.io/torrents/big-buck-bunny.torrent#ix=1 for the 2nd file in the torrent. Without this PR, this request passes the `IsWebtorrentInitiated(ctx)` condition and is therefore allowed to reach the network. Instead, we should confirm that the request is not for an individual file before letting it go to the network. That's what this commit does. Fixes: brave/brave-browser#3966
f073021
to
623a37f
Compare
Above was the test failure, which isn't relevant to this PR. |
@@ -41,6 +41,16 @@ bool URLMatched(const GURL& url) { | |||
base::CompareCase::INSENSITIVE_ASCII); | |||
} | |||
|
|||
/** | |||
* Returns true if the URL contains a URL fragment that starts with "ix=". For |
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.
@feross Just some nits - we use google/chromium style guide that requires //
-style comments
request->set_initiator(url::Origin::Create( | ||
torrent_extension_url().GetOrigin())); | ||
scoped_refptr<net::HttpResponseHeaders> orig_response_headers = | ||
new net::HttpResponseHeaders(std::string()); |
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.
it is handy to use clang-format
to make whitespaces CC-conformant
@iefremov Lmk if you want me to send a PR to fix these issues. |
In short, this PR does not redirect URL requests with
#ix=
to the .torrent file.When the user clicks on a file in the torrent file list, a new tab opens which points to the .torrent file, but with a file fragment appended. For example, the torrent https://webtorrent.io/torrents/big-buck-bunny.torrent would have a link to https://webtorrent.io/torrents/big-buck-bunny.torrent#ix=1 for the 2nd file in the torrent.
Without this PR, this request passes the
IsWebtorrentInitiated(ctx)
condition and is therefore allowed to reach the network. Instead, we should confirm that the request is not for an individual file before letting it go to the network. That's what this PR does.Fixes: brave/brave-browser#3966
Branched from this PR: #2989 (so merge after that one is merged)
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
After-merge Checklist:
changes has landed on.