mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #18882 - KiChjang:fix-origin, r=jdm
Use the correct origin in fetch Fixes #18147. <!-- 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/18882) <!-- Reviewable:end -->
This commit is contained in:
commit
c9884604e9
2 changed files with 6 additions and 4 deletions
|
@ -118,7 +118,7 @@ pub fn main_fetch(request: &mut Request,
|
||||||
// TODO: handle upgrade to a potentially secure URL.
|
// TODO: handle upgrade to a potentially secure URL.
|
||||||
|
|
||||||
// Step 5.
|
// 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())));
|
response = Some(Response::network_error(NetworkError::Internal("Request attempted on bad port".into())));
|
||||||
}
|
}
|
||||||
// TODO: handle blocking as mixed content.
|
// TODO: handle blocking as mixed content.
|
||||||
|
|
|
@ -670,8 +670,10 @@ pub fn http_redirect_fetch(request: &mut Request,
|
||||||
request.redirect_count += 1;
|
request.redirect_count += 1;
|
||||||
|
|
||||||
// Step 7
|
// Step 7
|
||||||
// FIXME: Correctly use request's origin
|
let same_origin = match request.origin {
|
||||||
let same_origin = location_url.origin() == request.current_url().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);
|
let has_credentials = has_credentials(&location_url);
|
||||||
|
|
||||||
if request.mode == RequestMode::CorsMode && !same_origin && has_credentials {
|
if request.mode == RequestMode::CorsMode && !same_origin && has_credentials {
|
||||||
|
@ -690,7 +692,7 @@ pub fn http_redirect_fetch(request: &mut Request,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 10
|
// Step 10
|
||||||
if cors_flag && !same_origin {
|
if cors_flag && location_url.origin() != request.current_url().origin() {
|
||||||
request.origin = Origin::Origin(ImmutableOrigin::new_opaque());
|
request.origin = Origin::Origin(ImmutableOrigin::new_opaque());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue