Skip to content
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

Implement referrer policy delivery by header #12441

Merged
merged 4 commits into from Jul 15, 2016

Conversation

@aravind-pg
Copy link
Contributor

aravind-pg commented Jul 14, 2016

Adds a new Option<ReferrerPolicy> field to Document and sets it appropriately in ScriptThread::load if a Referrer-Policy header is present.

r? @jdm

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #11860
  • There are tests for these changes

This change is Reviewable

@highfive
Copy link

highfive commented Jul 14, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/document.rs, components/script/dom/xmlhttprequest.rs, components/script/dom/domparser.rs, components/script/script_thread.rs, components/script/dom/domimplementation.rs, components/script/parse/html.rs, components/script/dom/node.rs, components/script/dom/xmldocument.rs
@jdm
Copy link
Member

jdm commented Jul 14, 2016

Great work!
-S-awaiting-review +S-needs-code-changes


Reviewed 2 of 2 files at r1, 8 of 8 files at r2, 26 of 26 files at r3.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


components/script/script_thread.rs, line 1713 [r2] (raw file):

        };

        use hyper::header::ReferrerPolicy as ReferrerPolicyHeader;

Let's add this with the other imports at the top of the file.


components/script/script_thread.rs, line 1715 [r2] (raw file):

        use hyper::header::ReferrerPolicy as ReferrerPolicyHeader;
        let referrer_policy = if let Some(headers) = metadata.headers {
            match headers.get::<ReferrerPolicyHeader>() {
headers.get::<ReferrerPolicyHeader>().map(|h| match *h {
    ReferrerPolicyHeader::NoReferrer => ReferrerPolicy::NoReferrer,
    //etc
})

components/script/dom/document.rs, line 1662 [r2] (raw file):

        // Once other delivery methods are implemented, make the unset case really
        // unset (i.e. None).
        let referrer_policy = if referrer_policy.is_some() {

let referrer_policy = referrer_policy.or(Some(ReferrerPolicy::NoReferrer));


Comments from Reviewable

@aravind-pg aravind-pg force-pushed the aravind-pg:referrer-pol-header branch from 2418ea8 to 0488d5d Jul 14, 2016
@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 14, 2016

Review status: 34 of 36 files reviewed at latest revision, 3 unresolved discussions.


components/script/script_thread.rs, line 1713 [r2] (raw file):

Previously, jdm (Josh Matthews) wrote…

Let's add this with the other imports at the top of the file.

Done. Do you think it yould nice to add a `use ReferrerPolicy::*;` locally to make things more readable? Bit noisy at present.

components/script/script_thread.rs, line 1715 [r2] (raw file):

Previously, jdm (Josh Matthews) wrote…

headers.get::<ReferrerPolicyHeader>().map(|h| match *h {
    ReferrerPolicyHeader::NoReferrer => ReferrerPolicy::NoReferrer,
    //etc
})
Great suggestion, done.

components/script/dom/document.rs, line 1662 [r2] (raw file):

Previously, jdm (Josh Matthews) wrote…

let referrer_policy = referrer_policy.or(Some(ReferrerPolicy::NoReferrer));

Nice, done.

Comments from Reviewable

@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 14, 2016

Incidentally, is there any interest in renaming NoRefWhenDowngrade NoReferrerWhenDowngrade? Right it now it sticks out a bit as being somewhat inconsistent with the other variants.

@jdm
Copy link
Member

jdm commented Jul 14, 2016

I agree, renaming that variant would make it more consistent.
-S-awaiting-review +S-needs-code-changes


Reviewed 2 of 2 files at r4.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


components/script/script_thread.rs, line 1713 [r2] (raw file):

Previously, aravind-pg (Aravind Gollakota) wrote…

Done. Do you think it yould nice to add a use ReferrerPolicy::*; locally to make things more readable? Bit noisy at present.

I could go either way. I think it's fine as-is.

components/script/script_thread.rs, line 1725 [r4] (raw file):

                    ReferrerPolicy::Origin,
                ReferrerPolicyHeader::OriginWhenCrossOrigin =>
                    ReferrerPolicyHeader::OriginWhenCrossOrigin,

This doesn't look like it compiles :)


Comments from Reviewable

@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 14, 2016

Whoops! Will fix later today

On 14 Jul 2016 8:55 a.m., "Josh Matthews" notifications@github.com wrote:

I agree, renaming that variant would make it more consistent.

-S-awaiting-review +S-needs-code-changes

Reviewed 2 of 2 files at r4.
Review status: all files reviewed at latest revision, 2 unresolved

discussions.

components/script/script_thread.rs, line 1713 [r2]
https://reviewable.io:443/reviews/servo/servo/12441#-KMdjNEormtv4e_XqDVT:-KMe6C9XIv89MIcx-Xut:1982670286
(raw file

use hyper::header::ReferrerPolicy as ReferrerPolicyHeader;
):
Previously, aravind-pg (Aravind Gollakota) wrote…

Done. Do you think it yould nice to add a use ReferrerPolicy::*; locally
to make things more readable? Bit noisy at present.

I could go either way. I think it's fine as-is.


components/script/script_thread.rs, line 1725 [r4]
https://reviewable.io:443/reviews/servo/servo/12441#-KMe69AXHbK77F_vL0cL:-KMe69AXHbK77F_vL0cM:-255094659
(raw file

ReferrerPolicyHeader::OriginWhenCrossOrigin,
):

                ReferrerPolicy::Origin,
            ReferrerPolicyHeader::OriginWhenCrossOrigin =>
                ReferrerPolicyHeader::OriginWhenCrossOrigin,

This doesn't look like it compiles :)

Comments from Reviewable
https://reviewable.io:443/reviews/servo/servo/12441#-:-KMe6UuGxouGaD9f_bvr:1979839934


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#12441 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AGl8UxBddFQtKOEI9lKChQ2lVO5PLrgSks5qVlv5gaJpZM4JMFU1
.

@bors-servo
Copy link
Contributor

bors-servo commented Jul 14, 2016

The latest upstream changes (presumably #12416) made this pull request unmergeable. Please resolve the merge conflicts.

@aravind-pg aravind-pg force-pushed the aravind-pg:referrer-pol-header branch from 0488d5d to d188236 Jul 15, 2016
@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 15, 2016

Rebased, renamed the variant and fixed the compile-error typo.


Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


components/script/script_thread.rs, line 1713 [r2] (raw file):

Previously, jdm (Josh Matthews) wrote…

I could go either way. I think it's fine as-is.

I'll just leave it as-is then.

components/script/script_thread.rs, line 1725 [r4] (raw file):

Previously, jdm (Josh Matthews) wrote…

This doesn't look like it compiles :)

Fixed!

Comments from Reviewable

@aravind-pg aravind-pg force-pushed the aravind-pg:referrer-pol-header branch from d188236 to bfda32e Jul 15, 2016
@jdm
Copy link
Member

jdm commented Jul 15, 2016

@bors-servo: r+
Yay!


Reviewed 30 of 30 files at r5, 8 of 8 files at r6, 26 of 26 files at r7, 6 of 6 files at r8.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@bors-servo
Copy link
Contributor

bors-servo commented Jul 15, 2016

📌 Commit bfda32e has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Jul 15, 2016

Testing commit bfda32e with merge b382cc2...

bors-servo added a commit that referenced this pull request Jul 15, 2016
Implement referrer policy delivery by header

Adds a new `Option<ReferrerPolicy>` field to Document and sets it appropriately in `ScriptThread::load` if a Referrer-Policy header is present.

r? @jdm

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11860
- [X] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12441)
<!-- Reviewable:end -->
@bors-servo bors-servo mentioned this pull request Jul 15, 2016
4 of 4 tasks complete
@bors-servo
Copy link
Contributor

bors-servo commented Jul 15, 2016

@bors-servo bors-servo merged commit bfda32e into servo:master Jul 15, 2016
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Jul 15, 2016
4 of 4 tasks complete
@aravind-pg aravind-pg deleted the aravind-pg:referrer-pol-header branch Jul 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants
You can’t perform that action at this time.