mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
check same-origin and url against the blob beign revoked
This commit is contained in:
parent
dfa78986a6
commit
2d995ba41a
4 changed files with 18 additions and 47 deletions
|
@ -40,9 +40,17 @@ pub struct BlobBuf {
|
||||||
/// <https://w3c.github.io/FileAPI/#DefinitionOfScheme>
|
/// <https://w3c.github.io/FileAPI/#DefinitionOfScheme>
|
||||||
pub fn parse_blob_url(url: &ServoUrl) -> Result<(Uuid, FileOrigin), ()> {
|
pub fn parse_blob_url(url: &ServoUrl) -> Result<(Uuid, FileOrigin), ()> {
|
||||||
let url_inner = Url::parse(url.path()).map_err(|_| ())?;
|
let url_inner = Url::parse(url.path()).map_err(|_| ())?;
|
||||||
|
let segs = url_inner
|
||||||
|
.path_segments()
|
||||||
|
.map(|c| c.collect::<Vec<_>>())
|
||||||
|
.ok_or(())?;
|
||||||
|
|
||||||
|
if url.query().is_some() || segs.len() > 1 {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
|
||||||
let id = {
|
let id = {
|
||||||
let mut segs = url_inner.path_segments().ok_or(())?;
|
let id = segs.first().ok_or(())?;
|
||||||
let id = segs.nth(0).ok_or(())?;
|
|
||||||
Uuid::from_str(id).map_err(|_| ())?
|
Uuid::from_str(id).map_err(|_| ())?
|
||||||
};
|
};
|
||||||
Ok((id, get_blob_origin(&ServoUrl::from_url(url_inner))))
|
Ok((id, get_blob_origin(&ServoUrl::from_url(url_inner))))
|
||||||
|
|
|
@ -129,13 +129,15 @@ impl URL {
|
||||||
let origin = get_blob_origin(&global.get_url());
|
let origin = get_blob_origin(&global.get_url());
|
||||||
|
|
||||||
if let Ok(url) = ServoUrl::parse(&url) {
|
if let Ok(url) = ServoUrl::parse(&url) {
|
||||||
if let Ok((id, _)) = parse_blob_url(&url) {
|
if url.fragment().is_none() && origin == get_blob_origin(&url) {
|
||||||
let resource_threads = global.resource_threads();
|
if let Ok((id, _)) = parse_blob_url(&url) {
|
||||||
let (tx, rx) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
|
let resource_threads = global.resource_threads();
|
||||||
let msg = FileManagerThreadMsg::RevokeBlobURL(id, origin, tx);
|
let (tx, rx) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
|
||||||
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg));
|
let msg = FileManagerThreadMsg::RevokeBlobURL(id, origin, tx);
|
||||||
|
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg));
|
||||||
|
|
||||||
let _ = rx.recv().unwrap();
|
let _ = rx.recv().unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,9 @@
|
||||||
[url-with-fetch.any.worker.html]
|
[url-with-fetch.any.worker.html]
|
||||||
[url-with-fetch]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Only exact matches should revoke URLs, using fetch]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Appending a query string should cause fetch to fail]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Appending a path should cause fetch to fail]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Revoke blob URL after creating Request, will fetch]
|
[Revoke blob URL after creating Request, will fetch]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
||||||
[url-with-fetch.any.html]
|
[url-with-fetch.any.html]
|
||||||
[Untitled]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[url-with-fetch]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Only exact matches should revoke URLs, using fetch]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Appending a query string should cause fetch to fail]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Appending a path should cause fetch to fail]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Revoke blob URL after creating Request, will fetch]
|
[Revoke blob URL after creating Request, will fetch]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,9 @@
|
||||||
[url-with-xhr.any.html]
|
[url-with-xhr.any.html]
|
||||||
[Only exact matches should revoke URLs, using XHR]
|
|
||||||
expected: FAIL
|
|
||||||
[Appending a query string should cause XHR to fail]
|
|
||||||
expected: FAIL
|
|
||||||
[Appending a path should cause XHR to fail]
|
|
||||||
expected: FAIL
|
|
||||||
[Revoke blob URL after open(), will fetch]
|
[Revoke blob URL after open(), will fetch]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
||||||
[url-with-xhr.any.worker.html]
|
[url-with-xhr.any.worker.html]
|
||||||
[Only exact matches should revoke URLs, using XHR]
|
|
||||||
expected: FAIL
|
|
||||||
[Appending a query string should cause XHR to fail]
|
|
||||||
expected: FAIL
|
|
||||||
[Appending a path should cause XHR to fail]
|
|
||||||
expected: FAIL
|
|
||||||
[Revoke blob URL after open(), will fetch]
|
[Revoke blob URL after open(), will fetch]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue