mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update checking origin trustworthy align to spec
This commit is contained in:
parent
06803a2edb
commit
99a8ea26a1
4 changed files with 12 additions and 7 deletions
|
@ -74,14 +74,19 @@ impl UrlHelper {
|
|||
}
|
||||
// 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() == "http" || url.scheme() == "wss" {
|
||||
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 5
|
||||
// Step 6
|
||||
} else {
|
||||
url.scheme() == "file"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue