Use origin when manipulating cookies.

This commit is contained in:
Josh Matthews 2016-04-13 10:39:16 +02:00 committed by Ms2ger
parent fa42b452a0
commit 90454c279d

View file

@ -2519,10 +2519,11 @@ impl DocumentMethods for Document {
return Ok(DOMString::new()); return Ok(DOMString::new());
} }
let url = self.url(); if !self.origin.is_scheme_host_port_tuple() {
if !is_scheme_host_port_tuple(&url) {
return Err(Error::Security); return Err(Error::Security);
} }
let url = self.url();
let (tx, rx) = ipc::channel().unwrap(); let (tx, rx) = ipc::channel().unwrap();
let _ = self.window.resource_thread().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP)); let _ = self.window.resource_thread().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
let cookies = rx.recv().unwrap(); let cookies = rx.recv().unwrap();
@ -2535,10 +2536,11 @@ impl DocumentMethods for Document {
return Ok(()); return Ok(());
} }
let url = self.url(); if !self.origin.is_scheme_host_port_tuple() {
if !is_scheme_host_port_tuple(url) {
return Err(Error::Security); return Err(Error::Security);
} }
let url = self.url();
let _ = self.window let _ = self.window
.resource_thread() .resource_thread()
.send(SetCookiesForUrl((*url).clone(), String::from(cookie), NonHTTP)); .send(SetCookiesForUrl((*url).clone(), String::from(cookie), NonHTTP));
@ -2742,10 +2744,6 @@ impl DocumentMethods for Document {
} }
} }
fn is_scheme_host_port_tuple(url: &Url) -> bool {
url.host().is_some() && url.port_or_default().is_some()
}
fn update_with_current_time_ms(marker: &Cell<u64>) { fn update_with_current_time_ms(marker: &Cell<u64>) {
if marker.get() == Default::default() { if marker.get() == Default::default() {
let time = time::get_time(); let time = time::get_time();