Closed
Bug 1186072
Opened 9 years ago
Closed 9 years ago
Add trailing slash to referer header when referrer policy is set
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla48
Tracking | Status | |
---|---|---|
firefox48 | --- | fixed |
People
(Reporter: franziskus, Assigned: tnguyen)
References
Details
(Whiteboard: tpe-seceng)
Attachments
(4 files, 1 obsolete file)
An origin referer header sent by Firefox does not include a trailing slash (neither does the origin header). While it is not clear to me whether this should be the case or not, this breaks W3C web platform tests for referer policies [1]. Also see [2] (not sure though why Mike says Firefox does include the trailing slash).
[1] https://github.com/w3c/web-platform-tests/tree/master/referrer-policy
[2] https://github.com/w3c/webappsec/issues/382
Comment 1•9 years ago
|
||
As far as the "Origin" header goes, the specification for that is at https://fetch.spec.whatwg.org/#origin-header and most definitely does NOT include the trailing slash in the BNF. If you look at the processing model, https://fetch.spec.whatwg.org/#http-network-or-cache-fetch step 7 uses https://html.spec.whatwg.org/multipage/browsers.html#ascii-serialisation-of-an-origin which also clearly does not include the trailing slash. I would be _very_ surprised if any browser includes a trailing slash in the "Origin" header.
For "Referer", we could include the trailing "/" when it's not "null", sure.
Reporter | ||
Comment 2•9 years ago
|
||
Ok, agree. This seems to be a referrer policy bug [1], i.e. the referer header has a trailing slash if it is actually only an origin, but is missing one if a referrer policy is set that forces the referer header to be set to the origin.
[1] https://github.com/w3c/webappsec/issues/382#issuecomment-123513647
Summary: Add trailing slash to referer/origin header → Add trailing slash to referer header when referrer policy is set
Reporter | ||
Comment 3•9 years ago
|
||
This is a hot fix for adding a trailing slash to the referer header when a referrer policy is set and fixes tests accordingly. We might want to move this to nsStandardURL and use something else than nsStandardURL::GetPrePath here (add something like GetOrigin to nsIURI.idl that returns essentially the same thing as GetPrePath but with a trailing slash, I don't think we can use any of the existing functions for this).
Reporter | ||
Comment 4•9 years ago
|
||
this patch is already a bit old and would probably have to be rebased, but in order to get web-platform tests working we have to land something like this. Christoph/Steve, would you know a better place to do this or shall we do it in HttpBaseChannel?
Flags: needinfo?(sworkman)
Flags: needinfo?(mozilla)
Comment 5•9 years ago
|
||
After a quick glance through DXR and since it's an HTTP header, I think putting it in HttpBaseChannel makes sense.
(Interestingly, the Origin header is special cased in nsHttpRequestHead - it has its own functions in that class, but Referer is just another header in the array. So it should be isolated from any changes you make to Referer).
Flags: needinfo?(sworkman)
Comment 6•9 years ago
|
||
(In reply to Franziskus Kiefer [:fkiefer or :franziskus] from comment #4)
> this patch is already a bit old and would probably have to be rebased, but
> in order to get web-platform tests working we have to land something like
> this. Christoph/Steve, would you know a better place to do this or shall we
> do it in HttpBaseChannel?
I agree, it can live in HttpBaseChannel. Please make sure to replace
> spec = spec + NS_LITERAL_CSTRING("/");
with something like
> spec.AppendLiteral("/"); [or whatever equivalent append functionality exists on nsAutoCString].
Flags: needinfo?(mozilla)
Reporter | ||
Comment 7•9 years ago
|
||
Reporter | ||
Comment 8•9 years ago
|
||
Reporter | ||
Updated•9 years ago
|
Assignee: nobody → franziskuskiefer
Reporter | ||
Updated•9 years ago
|
Attachment #8638055 -
Attachment is obsolete: true
Reporter | ||
Comment 9•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/36639/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/36639/
Attachment #8723587 -
Flags: review?(mozilla)
Reporter | ||
Updated•9 years ago
|
Attachment #8723587 -
Flags: review?(sworkman)
Comment 10•9 years ago
|
||
Comment on attachment 8723587 [details]
MozReview Request: Bug 1186072 - add trailing slash to origin referer header when policy is set, r=sworkman
https://reviewboard.mozilla.org/r/36639/#review33235
1 question, 1 nit. Otherwise r=me - thanks Franziskus!
::: dom/base/test/bug704320_counter.sjs:44
(Diff revision 1)
> - } else if (referrer == "http://mochi.test:8888") {
> + } else if (referrer.indexOf("http://mochi.test:8888") == 0) {
What if the referrer has "http://mochi.test:8888" at the start of the string, but the path is wrong? Do you need to worry about that here? Is it better to look for "http://mochi.test:8888/" - i.e. origin with a trailing slash?
::: netwerk/protocol/http/HttpBaseChannel.cpp:1498
(Diff revision 1)
> + spec.AppendLiteral("/");
It would be nice to be explicit in the preceding comment that a trailing slash is required per spec.
Attachment #8723587 -
Flags: review?(sworkman)
Comment 11•9 years ago
|
||
Comment on attachment 8723587 [details]
MozReview Request: Bug 1186072 - add trailing slash to origin referer header when policy is set, r=sworkman
https://reviewboard.mozilla.org/r/36639/#review33505
Looks good to me, please answers Steve's question. r=me
Attachment #8723587 -
Flags: review?(mozilla) → review+
Reporter | ||
Comment 12•9 years ago
|
||
https://reviewboard.mozilla.org/r/36639/#review33235
> What if the referrer has "http://mochi.test:8888" at the start of the string, but the path is wrong? Do you need to worry about that here? Is it better to look for "http://mochi.test:8888/" - i.e. origin with a trailing slash?
I can't remember why, but someone thought this would be a good idea and I let me convince to do it. Nevertheless, we should check == here.
Reporter | ||
Comment 13•9 years ago
|
||
Reporter | ||
Comment 14•9 years ago
|
||
Comment on attachment 8723587 [details]
MozReview Request: Bug 1186072 - add trailing slash to origin referer header when policy is set, r=sworkman
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/36639/diff/1-2/
Attachment #8723587 -
Attachment description: MozReview Request: Bug 1186072 - add trailing slash to origin referer header when policy is set, r?ckerschb → MozReview Request: Bug 1186072 - add trailing slash to origin referer header when policy is set, r?sworkman
Attachment #8723587 -
Flags: review?(sworkman)
Comment 15•9 years ago
|
||
Comment on attachment 8723587 [details]
MozReview Request: Bug 1186072 - add trailing slash to origin referer header when policy is set, r=sworkman
https://reviewboard.mozilla.org/r/36639/#review33721
Thanks Franziskus! r=me.
Attachment #8723587 -
Flags: review?(sworkman) → review+
Comment 16•9 years ago
|
||
Please note the test that I just landed, see for example: <https://hg.mozilla.org/integration/mozilla-inbound/rev/fc5cc380ddb3#l2.60>. This test is doing this dance because of this bug and will probably (hopefully!) fail with your patch. Please switch <https://hg.mozilla.org/integration/mozilla-inbound/rev/fc5cc380ddb3#l2.28> to compare against expectedReferrerSpec and drop expectedReferrerHeader completely. Thanks!
Reporter | ||
Comment 17•9 years ago
|
||
Comment on attachment 8723587 [details]
MozReview Request: Bug 1186072 - add trailing slash to origin referer header when policy is set, r=sworkman
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/36639/diff/2-3/
Attachment #8723587 -
Attachment description: MozReview Request: Bug 1186072 - add trailing slash to origin referer header when policy is set, r?sworkman → MozReview Request: Bug 1186072 - add trailing slash to origin referer header when policy is set, r=sworkman
Reporter | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 18•9 years ago
|
||
Keywords: checkin-needed
Comment 19•9 years ago
|
||
backed out for test failures like https://treeherder.mozilla.org/logviewer.html#?job_id=22926320&repo=mozilla-inbound
Flags: needinfo?(franziskuskiefer)
Comment 20•9 years ago
|
||
Reporter | ||
Comment 21•9 years ago
|
||
Those tests have been working before because they're wrong [1]. We can either be spec compliant or pass the web platform tests at the moment. I'm not sure if passing those tests is more important.
[1] https://github.com/w3c/web-platform-tests/issues/2618
Flags: needinfo?(franziskuskiefer) → needinfo?(cbook)
Comment 22•9 years ago
|
||
Tests, like specs, are not handed down on stone tablets; they can be wrong. You can either fix the tests in-tree and they'll get updated upstream automagically, or you can update the annotations. See testing/web-platform/README.md for more docs, or ping me any time.
Comment 23•9 years ago
|
||
There is also documentation on MDN these days [1], in case you like that better. But yes, what Ms2ger said. For preference fix the tests. If that isn't possible for some reason, change the metadata.
[1] https://developer.mozilla.org/en-US/docs/Mozilla/QA/web-platform-tests
Comment 24•9 years ago
|
||
I think it should be fairly straightforward to fix the tests here.
Updated•9 years ago
|
Flags: needinfo?(cbook)
Assignee | ||
Comment 25•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/40041/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/40041/
Attachment #8730603 -
Flags: review?(franziskuskiefer)
Assignee | ||
Updated•9 years ago
|
Assignee: franziskuskiefer → tnguyen
Reporter | ||
Comment 26•9 years ago
|
||
Comment on attachment 8730603 [details]
MozReview Request: Bug 1186072 - web-platform-tests fetch origin referrer miss slash, r?fkiefer
https://reviewboard.mozilla.org/r/40041/#review36571
lgtm. But could you do a try run with this to see if this fixes all web platform test errors?
Could you also file a PR against the web platform tests upstream [1] to get this fixed?
[1] https://github.com/w3c/web-platform-tests/tree/master/fetch
Attachment #8730603 -
Flags: review?(franziskuskiefer) → review+
Comment 27•9 years ago
|
||
(In reply to Franziskus Kiefer [:fkiefer or :franziskus] from comment #26)
> Could you also file a PR against the web platform tests upstream [1] to get
> this fixed?
The neat thing is that this will happen automagically once this commit lands into m-c.
Reporter | ||
Comment 28•9 years ago
|
||
(In reply to :Ms2ger from comment #27)
> (In reply to Franziskus Kiefer [:fkiefer or :franziskus] from comment #26)
> > Could you also file a PR against the web platform tests upstream [1] to get
> > this fixed?
>
> The neat thing is that this will happen automagically once this commit lands
> into m-c.
oh, I didn't know about that. That's cool. Well, then ignore that part of the comment Thomas.
Assignee | ||
Comment 29•9 years ago
|
||
(In reply to Franziskus Kiefer [:fkiefer or :franziskus] from comment #26)
> Comment on attachment 8730603 [details]
> MozReview Request: Bug 1186072 - web-platform-tests fetch origin referrer
> miss slash, r?fkiefer
>
> https://reviewboard.mozilla.org/r/40041/#review36571
>
> lgtm. But could you do a try run with this to see if this fixes all web
> platform test errors?
>
Thanks for looking into the patch.
referrer-policy test cases still fail for example in the try run.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=efb9c620463a.
Failure example
TEST-UNEXPECTED-PASS | /referrer-policy/origin-only/http-csp/cross-origin/http-http/fetch-request/generic.keep-origin-redirect.http.html | The referrer URL is origin when a
This is due to FAIL expectation data in metadata file. I think it should be set to PASS instead of.
Let me change and run a new try.
Thanks
Comment 30•9 years ago
|
||
(In reply to Thomas Nguyen[:tnguyen][:thomas][:nguyen] from comment #29)
> This is due to FAIL expectation data in metadata file. I think it should be
> set to PASS instead of.
No. Since that is the only expected failure in that ini file, you can remove the ini file completely since after getting rid of that expected failure, there's nothing more left in the file that is useful. Note that you can also run these tests locally after removing that ini file (and other similar ones), for example by running:
./mach web-platform-tests /referrer-policy/
Assignee | ||
Comment 31•9 years ago
|
||
Comment on attachment 8730603 [details]
MozReview Request: Bug 1186072 - web-platform-tests fetch origin referrer miss slash, r?fkiefer
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/40041/diff/1-2/
Assignee | ||
Comment 32•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/40729/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/40729/
Attachment #8731584 -
Flags: review?(franziskuskiefer)
Assignee | ||
Comment 33•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/40731/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/40731/
Attachment #8731585 -
Flags: review?(franziskuskiefer)
Assignee | ||
Comment 34•9 years ago
|
||
(In reply to :Ehsan Akhgari from comment #30)
> Since that is the only expected failure in that ini file, you can
> remove the ini file completely since after getting rid of that expected
> failure, there's nothing more left in the file that is useful.
Thanks Ehsan
Try result:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=34eaffa946ed
Reporter | ||
Updated•9 years ago
|
Attachment #8731584 -
Flags: review?(franziskuskiefer) → review+
Reporter | ||
Comment 35•9 years ago
|
||
Comment on attachment 8731584 [details]
MozReview Request: Bug 1186072 - fix web-platform-tests service worker fetch , r?fkiefer
https://reviewboard.mozilla.org/r/40729/#review37639
lgtm
Reporter | ||
Comment 36•9 years ago
|
||
Comment on attachment 8731585 [details]
MozReview Request: Bug 1186072 - Run referrer-policy web platform tests expected pass, r?fkiefer
https://reviewboard.mozilla.org/r/40731/#review37641
I presume that's all files, didn't check them individually. But judging from the try run it's all good.
Attachment #8731585 -
Flags: review?(franziskuskiefer) → review+
Comment 37•9 years ago
|
||
Franziskus, looks like we need to get someone else (or more than one person) to do final reviews on these patches, right?
Flags: needinfo?(franziskuskiefer)
Comment 38•9 years ago
|
||
(In reply to Steve Workman [:sworkman] (please use needinfo) from comment #37)
> Franziskus, looks like we need to get someone else (or more than one person)
> to do final reviews on these patches, right?
r=me. :-)
Comment 39•9 years ago
|
||
Awesome! Thanks Ehsan :)
Updated•9 years ago
|
Flags: needinfo?(franziskuskiefer)
Assignee | ||
Comment 40•9 years ago
|
||
https://reviewboard.mozilla.org/r/40731/#review37641
I only changed expected=pass for expected=fail to correct failed test cases. Some "disabled" test cases still remains (for example image tag test cases will be disabled due to https://github.com/w3c/web-platform-tests/issues/1874)
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 41•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/768bd20b25ae
https://hg.mozilla.org/integration/fx-team/rev/87b00f4843cc
https://hg.mozilla.org/integration/fx-team/rev/ca466d057591
https://hg.mozilla.org/integration/fx-team/rev/e10424cf620f
Keywords: checkin-needed
Updated•9 years ago
|
Whiteboard: tpe-seceng
Comment 42•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/768bd20b25ae
https://hg.mozilla.org/mozilla-central/rev/87b00f4843cc
https://hg.mozilla.org/mozilla-central/rev/ca466d057591
https://hg.mozilla.org/mozilla-central/rev/e10424cf620f
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•