mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Conform conditionals regarding cookie removal with spec
This commit is contained in:
parent
fd5733fc1e
commit
64b456f0e2
1 changed files with 7 additions and 5 deletions
|
@ -37,7 +37,7 @@ impl CookieStorage {
|
||||||
let domain = reg_host(cookie.cookie.domain.as_ref().unwrap_or(&"".to_string()));
|
let domain = reg_host(cookie.cookie.domain.as_ref().unwrap_or(&"".to_string()));
|
||||||
let cookies = self.cookies_map.entry(domain).or_insert(vec![]);
|
let cookies = self.cookies_map.entry(domain).or_insert(vec![]);
|
||||||
|
|
||||||
// Step 1
|
// Step 11.1
|
||||||
let position = cookies.iter().position(|c| {
|
let position = cookies.iter().position(|c| {
|
||||||
c.cookie.domain == cookie.cookie.domain &&
|
c.cookie.domain == cookie.cookie.domain &&
|
||||||
c.cookie.path == cookie.cookie.path &&
|
c.cookie.path == cookie.cookie.path &&
|
||||||
|
@ -45,15 +45,16 @@ impl CookieStorage {
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(ind) = position {
|
if let Some(ind) = position {
|
||||||
|
// Step 11.4
|
||||||
let c = cookies.remove(ind);
|
let c = cookies.remove(ind);
|
||||||
|
|
||||||
// http://tools.ietf.org/html/rfc6265#section-5.3 step 11.2
|
// http://tools.ietf.org/html/rfc6265#section-5.3 step 11.2
|
||||||
if !c.cookie.httponly || source == CookieSource::HTTP {
|
if c.cookie.httponly && source == CookieSource::NonHTTP {
|
||||||
Ok(Some(c))
|
|
||||||
} else {
|
|
||||||
// Undo the removal.
|
// Undo the removal.
|
||||||
cookies.push(c);
|
cookies.push(c);
|
||||||
Err(())
|
Err(())
|
||||||
|
} else {
|
||||||
|
Ok(Some(c))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
@ -83,7 +84,7 @@ impl CookieStorage {
|
||||||
cookies.retain(|c| !is_cookie_expired(&c));
|
cookies.retain(|c| !is_cookie_expired(&c));
|
||||||
let new_len = cookies.len();
|
let new_len = cookies.len();
|
||||||
|
|
||||||
// https://datatracker.ietf.org/doc/draft-ietf-httpbis-cookie-alone
|
// https://www.ietf.org/id/draft-ietf-httpbis-cookie-alone-01.txt
|
||||||
if new_len == old_len && !evict_one_cookie(cookie.cookie.secure, cookies) {
|
if new_len == old_len && !evict_one_cookie(cookie.cookie.secure, cookies) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -159,6 +160,7 @@ impl CookieStorage {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reg_host<'a>(url: &'a str) -> String {
|
fn reg_host<'a>(url: &'a str) -> String {
|
||||||
reg_suffix(url).to_string()
|
reg_suffix(url).to_string()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue