browser.downloads.download() should allow setting Referer (and others)
Categories
(WebExtensions :: General, enhancement, P5)
Tracking
(firefox70 fixed)
Tracking | Status | |
---|---|---|
firefox70 | --- | fixed |
People
(Reporter: none11given, Assigned: evilpie)
References
Details
(Keywords: dev-doc-complete, Whiteboard: [design-decision-approved][triaged])
Attachments
(1 file)
Updated•7 years ago
|
Comment 1•7 years ago
|
||
Updated•7 years ago
|
Comment 2•7 years ago
|
||
Reporter | ||
Comment 3•7 years ago
|
||
Comment 4•7 years ago
|
||
Updated•7 years ago
|
Updated•7 years ago
|
Updated•6 years ago
|
Comment 9•6 years ago
|
||
Assignee | ||
Comment 10•5 years ago
|
||
This is something that would be useful to DownThemAll! (https://github.com/downthemall/downthemall/blob/master/TODO.md) and should be really simple to implement.
Assignee | ||
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Comment 11•5 years ago
|
||
Echoing comment 8, if we allow Referer
, we should also consider allowing Cookie
, both are useful for downloading from pages that require login.
I see we copied the headers restrictions from Chrome, do we have an idea of the rational here? I would imagine if we allow Cookie you could trigger remote endpoints with the users' credentials, which might be unexpected for an extension that only has the download permission, but no hosts permission.
Assignee | ||
Comment 12•5 years ago
|
||
Oh, the users' cookie is automatically included anyway. In that case I see no problem with also allowing Referer
. Even setting Cookie
might be okay, because if we already provide the user's cookie, what could really be worse?
Assignee | ||
Comment 13•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Comment 14•5 years ago
•
|
||
I see we copied the headers restrictions from Chrome, do we have an idea of the rational here?
It might be from Chrome, but the list actually references the Fetch spec. It probably made sense to copy Chrome if we're going for compat, and It was a safe choice by default, without going into details of each header.
https://fetch.spec.whatwg.org/#forbidden-header-name
About Referer specifically, I can see two subtle issues:
- If your extension has
a.com
host permission, it can modify the download headers and insertb.com
as Referer, - but If it has
b.com
permission, there are ways to trigger a load froma.com
withb.com
as a Referer (ie embedding an image).
I'm not sure which one is more surprising, but since either workaround doesn't already require both permissions, I think we can allow the header for downloads without any host permissions.
I would imagine if we allow Cookie you could trigger remote endpoints with the users' credentials, which might be unexpected for an extension that only has the download permission, but no hosts permission.
Cookies already require host permissions, so we wouldn't want to relax that. Checking permissions would be possible, but not sure it's worth it without a good use case that isn't covered by just using the cookies api.
Comment 15•5 years ago
|
||
Comment 16•5 years ago
|
||
bugherder |
Comment 17•5 years ago
|
||
Hello,
Will this fix require manual validation? If yes, please provide some steps to reproduce in order to correctly test it and also, please set the "qe-verify+" flag. Otherwise, could the "qe-verify-" flag be added? Thanks!
Assignee | ||
Comment 18•5 years ago
|
||
No thank you. I am sure the automated test is enough.
Comment 19•5 years ago
|
||
Thank you. Setting the "qe-verify-" flag as per the above comment.
Comment 20•5 years ago
|
||
Hi Tom, looking for some advice on the documentation changes needed. Is this as simple as adding:
referrer | optional
A string representing the URL of the document requesting the download. Use this parameter where the site you are downloading from expects requests from specific pages.
With the browser compatibility details updated to show support from Firefox 70?
Thanks!
Assignee | ||
Comment 21•5 years ago
|
||
No, Referer
can be used inside with the headers
field now. So the sentence
restricted to those allowed by
XMLHttpRequest
.
needs to be adjusted like
restricted to those allowed by
XMLHttpRequest
except forReferer
.
Comment 22•5 years ago
|
||
Not "except" really... That, to me, implies Referer
is not allowed.
So maybe something like this, to avoid ambiguity.
An array of objects representing extra HTTP headers to send with the request if the URL uses the HTTP[s] protocol. Each header is represented as a dictionary object containing the keys name and either value or binaryValue. Allowed are the same headers that are allowed by XMLHttpRequest. Firefox 70 and later additionally allows the
Referer
header. Any attempt to use any header that is not allowed will throw an error.
(Changes in italics)
And for the compat table, it should be noted that Referer
is an allowed header since Firefox 70, but not allowed in other browsers (yet).
Comment 23•5 years ago
|
||
hmm... The XMLHttpRequest link should better be replaced by a link to https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name
And that is a list of blacklisted headers not a list of whitelisted ones.
So maybe
An array of objects representing extra HTTP headers to send with the request if the URL uses the HTTP[s] protocol. Each header is represented as a dictionary object containing the keys name and either value or binaryValue. Forbidden are the same headers that are forbidden by
XMLHttpRequest
andfetch
, except Firefox 70 and later also allows the use of theReferer
header. Any attempt to use any forbidden header will throw an error.
Comment 24•5 years ago
|
||
Many thanks for the feedback and suggestions. I've made the changes to downloads.download() as well as the browser compatibility table.
Updated•5 years ago
|
Description
•