Skip to content

Commit

Permalink
Allow for redirects after a CORS-preflight
Browse files Browse the repository at this point in the history
  • Loading branch information
ferjm committed Mar 10, 2017
1 parent c584f39 commit 469eb19
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 16 deletions.
3 changes: 1 addition & 2 deletions components/net/fetch/methods.rs
Expand Up @@ -17,7 +17,7 @@ use hyper::mime::{Mime, SubLevel, TopLevel};
use hyper::status::StatusCode;
use mime_guess::guess_mime_type;
use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy};
use net_traits::request::{RedirectMode, Referrer, Request, RequestMode, ResponseTainting};
use net_traits::request::{Referrer, Request, RequestMode, ResponseTainting};
use net_traits::request::{Type, Origin, Window};
use net_traits::response::{Response, ResponseBody, ResponseType};
use std::borrow::Cow;
Expand Down Expand Up @@ -240,7 +240,6 @@ pub fn main_fetch(request: Rc<Request>,
(!is_simple_method(&request.method.borrow()) ||
request.headers.borrow().iter().any(|h| !is_simple_header(&h)))) {
request.response_tainting.set(ResponseTainting::CorsTainting);
request.redirect_mode.set(RedirectMode::Error);
let response = http_fetch(request.clone(), cache, true, true, false,
target, done_chan, context);
if response.is_network_error() {
Expand Down
6 changes: 1 addition & 5 deletions components/net/http_loader.rs
Expand Up @@ -746,11 +746,7 @@ fn http_redirect_fetch(request: Rc<Request>,
request.redirect_count.set(request.redirect_count.get() + 1);

// Step 7
let same_origin = if let Origin::Origin(ref origin) = *request.origin.borrow() {
*origin == request.current_url().origin()
} else {
false
};
let same_origin = location_url.origin()== request.current_url().origin();
let has_credentials = has_credentials(&location_url);

if request.mode == RequestMode::CorsMode && !same_origin && has_credentials {
Expand Down
17 changes: 17 additions & 0 deletions tests/wpt/metadata/cors/redirect-preflight.htm.ini
@@ -0,0 +1,17 @@
[redirect-preflight.htm]
type: testharness
[Disallow redirect 301 after succesful (200) preflight]
expected: FAIL

[Disallow redirect 302 after succesful (200) preflight]
expected: FAIL

[Disallow redirect 303 after succesful (200) preflight]
expected: FAIL

[Disallow redirect 307 after succesful (200) preflight]
expected: FAIL

[Disallow redirect 308 after succesful (200) preflight]
expected: FAIL

5 changes: 0 additions & 5 deletions tests/wpt/metadata/cors/redirect-userinfo.htm.ini

This file was deleted.

@@ -1,9 +1,5 @@
[eventsource-cross-origin.htm]
type: testharness
expected: TIMEOUT
[EventSource: cross-origin redirect use]
expected: TIMEOUT

[EventSource: cross-origin allow-origin: http://example.org should fail]
expected: FAIL

Expand Down
Expand Up @@ -8,3 +8,4 @@

[Check referrerPolicy init value of same-origin and associated getter]
expected: FAIL

Expand Up @@ -2,3 +2,4 @@
type: testharness
[Request has arrayBuffer method]
expected: FAIL

2 changes: 2 additions & 0 deletions tests/wpt/mozilla/meta/css/viewport_meta.html.ini
@@ -1 +1,3 @@
prefs: [layout.viewport.enabled:true]
[viewport_meta.html]
type: reftest
2 changes: 2 additions & 0 deletions tests/wpt/mozilla/meta/css/viewport_rule.html.ini
@@ -1 +1,3 @@
prefs: [layout.viewport.enabled:true]
[viewport_rule.html]
type: reftest

0 comments on commit 469eb19

Please sign in to comment.