mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fail fast on bad schemes
This commit is contained in:
parent
5f55cd5d71
commit
7ef644c1f7
3 changed files with 14 additions and 30 deletions
|
@ -32,7 +32,7 @@ use js::conversions::ToJSValConvertible;
|
|||
use js::jsval::UndefinedValue;
|
||||
use mime::{self, Mime};
|
||||
use net_traits::request::{CacheMode, CorsSettings, Destination, RequestBuilder};
|
||||
use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata};
|
||||
use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FilteredMetadata};
|
||||
use net_traits::{FetchResponseListener, FetchResponseMsg, NetworkError};
|
||||
use net_traits::{ResourceFetchTiming, ResourceTimingType};
|
||||
use servo_atoms::Atom;
|
||||
|
@ -339,7 +339,12 @@ impl FetchResponseListener for EventSourceContext {
|
|||
Ok(fm) => {
|
||||
let meta = match fm {
|
||||
FetchMetadata::Unfiltered(m) => m,
|
||||
FetchMetadata::Filtered { unsafe_, .. } => unsafe_,
|
||||
FetchMetadata::Filtered { unsafe_, filtered } => match filtered {
|
||||
FilteredMetadata::Opaque | FilteredMetadata::OpaqueRedirect => {
|
||||
return self.fail_the_connection()
|
||||
},
|
||||
_ => unsafe_,
|
||||
},
|
||||
};
|
||||
let mime = match meta.content_type {
|
||||
None => return self.fail_the_connection(),
|
||||
|
@ -352,7 +357,13 @@ impl FetchResponseListener for EventSourceContext {
|
|||
self.announce_the_connection();
|
||||
},
|
||||
Err(_) => {
|
||||
self.reestablish_the_connection();
|
||||
// The spec advises failing here if reconnecting would be
|
||||
// "futile", with no more specific advice; WPT tests
|
||||
// consider a non-http(s) scheme to be futile.
|
||||
match self.event_source.root().url.scheme() {
|
||||
"http" | "https" => self.reestablish_the_connection(),
|
||||
_ => self.fail_the_connection(),
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,3 @@
|
|||
|
||||
[dedicated worker - EventSource: constructor (act as if there is a network error) (https://example.not/test)]
|
||||
expected: FAIL
|
||||
|
||||
[dedicated worker - EventSource: constructor (act as if there is a network error) (ftp://example.not/)]
|
||||
expected: FAIL
|
||||
|
||||
[dedicated worker - EventSource: constructor (act as if there is a network error) (mailto:whatwg@awesome.example)]
|
||||
expected: FAIL
|
||||
|
||||
[dedicated worker - EventSource: constructor (act as if there is a network error) (javascript:alert('FAIL'))]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
[eventsource-constructor-non-same-origin.htm]
|
||||
type: testharness
|
||||
[EventSource: constructor (act as if there is a network error) (http://example.not/)]
|
||||
expected: FAIL
|
||||
|
||||
[EventSource: constructor (act as if there is a network error) (https://example.not/test)]
|
||||
expected: FAIL
|
||||
|
||||
[EventSource: constructor (act as if there is a network error) (ftp://example.not/)]
|
||||
expected: FAIL
|
||||
|
||||
[EventSource: constructor (act as if there is a network error) (mailto:whatwg@awesome.example)]
|
||||
expected: FAIL
|
||||
|
||||
[EventSource: constructor (act as if there is a network error) (javascript:alert('FAIL'))]
|
||||
expected: FAIL
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue