mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
make is_origin_trustworthy a method of ServoUrl + fix localhost handling
This commit is contained in:
parent
a7c5c97616
commit
357b486455
4 changed files with 30 additions and 46 deletions
|
@ -72,23 +72,4 @@ impl UrlHelper {
|
|||
pub fn SetUsername(url: &mut ServoUrl, value: USVString) {
|
||||
let _ = quirks::set_username(url.as_mut_url(), &value.0);
|
||||
}
|
||||
// https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
|
||||
pub fn is_origin_trustworthy(url: &ServoUrl) -> bool {
|
||||
// Step 1
|
||||
if !url.origin().is_tuple() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Step 3
|
||||
if url.scheme() == "https" || url.scheme() == "wss" {
|
||||
true
|
||||
// Step 4
|
||||
} else if url.host().is_some() {
|
||||
let host = url.host_str().unwrap();
|
||||
host == "127.0.0.0/8" || host == "::1/128"
|
||||
// Step 6
|
||||
} else {
|
||||
url.scheme() == "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue