Skip to content

Commit

Permalink
servo: Merge #18882 - Use the correct origin in fetch (from KiChjang:…
Browse files Browse the repository at this point in the history
…fix-origin); r=jdm

Fixes #18147.

Source-Repo: https://github.com/servo/servo
Source-Revision: c9884604e974937c45ca3dfc5afb23079536fd41
  • Loading branch information
KiChjang committed Nov 15, 2017
1 parent 5a8dd2e commit 0e56185
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion servo/components/net/fetch/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub fn main_fetch(request: &mut Request,
// TODO: handle upgrade to a potentially secure URL.

// Step 5.
if should_be_blocked_due_to_bad_port(&request.url()) {
if should_be_blocked_due_to_bad_port(&request.current_url()) {
response = Some(Response::network_error(NetworkError::Internal("Request attempted on bad port".into())));
}
// TODO: handle blocking as mixed content.
Expand Down
8 changes: 5 additions & 3 deletions servo/components/net/http_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,10 @@ pub fn http_redirect_fetch(request: &mut Request,
request.redirect_count += 1;

// Step 7
// FIXME: Correctly use request's origin
let same_origin = location_url.origin() == request.current_url().origin();
let same_origin = match request.origin {
Origin::Origin(ref origin) => *origin == location_url.origin(),
Origin::Client => panic!("Request origin should not be client for {}", request.current_url()),
};
let has_credentials = has_credentials(&location_url);

if request.mode == RequestMode::CorsMode && !same_origin && has_credentials {
Expand All @@ -690,7 +692,7 @@ pub fn http_redirect_fetch(request: &mut Request,
}

// Step 10
if cors_flag && !same_origin {
if cors_flag && location_url.origin() != request.current_url().origin() {
request.origin = Origin::Origin(ImmutableOrigin::new_opaque());
}

Expand Down

0 comments on commit 0e56185

Please sign in to comment.