Skip to content

Commit

Permalink
Add missing spec links
Browse files Browse the repository at this point in the history
  • Loading branch information
utsavoza committed Jun 29, 2020
1 parent cdd012e commit 358f4d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/net/fetch/methods.rs
Expand Up @@ -12,7 +12,7 @@ use content_security_policy as csp;
use crossbeam_channel::{unbounded, Receiver, Sender};
use devtools_traits::DevtoolsControlMsg;
use headers::{AccessControlExposeHeaders, ContentType, HeaderMapExt, Range};
use http::header::{HeaderMap, HeaderName};
use http::header::{self, HeaderMap, HeaderName};
use hyper::Method;
use hyper::StatusCode;
use ipc_channel::ipc::{self, IpcReceiver};
Expand Down Expand Up @@ -240,6 +240,7 @@ pub fn main_fetch(
let referrer_url = match mem::replace(&mut request.referrer, Referrer::NoReferrer) {
Referrer::NoReferrer => None,
Referrer::ReferrerUrl(referrer_source) | Referrer::Client(referrer_source) => {
request.headers.remove(header::REFERER);
determine_requests_referrer(
request.referrer_policy.unwrap(),
referrer_source,
Expand Down
3 changes: 3 additions & 0 deletions components/net/http_loader.rs
Expand Up @@ -251,6 +251,9 @@ fn strip_url_for_use_as_referrer(mut url: ServoUrl, origin_only: bool) -> Option
url.set_username("").unwrap();
url.set_password(None).unwrap();
url.set_fragment(None);
// Note: The result of serializing referrer url should not be
// greater than 4096 as specified in Step 6 of
// https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer
if origin_only || url.as_str().len() > MAX_REFERRER_URL_LENGTH {
url.set_path("");
url.set_query(None);
Expand Down
5 changes: 3 additions & 2 deletions components/url/lib.rs
Expand Up @@ -97,6 +97,7 @@ impl ServoUrl {
scheme == "https" || scheme == "wss"
}

/// <https://fetch.spec.whatwg.org/#local-scheme>
pub fn is_local_scheme(&self) -> bool {
let scheme = self.scheme();
scheme == "about" || scheme == "blob" || scheme == "data"
Expand Down Expand Up @@ -174,7 +175,7 @@ impl ServoUrl {
Ok(Self::from_url(Url::from_file_path(path)?))
}

// https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url
/// <https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url>
pub fn is_potentially_trustworthy(&self) -> bool {
// Step 1
if self.as_str() == "about:blank" || self.as_str() == "about:srcdoc" {
Expand All @@ -188,7 +189,7 @@ impl ServoUrl {
self.is_origin_trustworthy()
}

// https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
/// <https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy>
pub fn is_origin_trustworthy(&self) -> bool {
// Step 1
if !self.origin().is_tuple() {
Expand Down

0 comments on commit 358f4d2

Please sign in to comment.