зеркало из https://github.com/mozilla/gecko-dev.git
Bug 944616 - "Blob URLs don't allow query or fragment parts". r=bz
This commit is contained in:
Родитель
5147e1f0af
Коммит
c6d2d4f8dd
|
@ -419,16 +419,26 @@ GetDataInfo(const nsACString& aUri)
|
|||
}
|
||||
|
||||
DataInfo* res;
|
||||
nsCString uriIgnoringRef;
|
||||
int32_t hashPos = aUri.FindChar('#');
|
||||
if (hashPos < 0) {
|
||||
uriIgnoringRef = aUri;
|
||||
|
||||
// Let's remove any fragment and query from this URI.
|
||||
int32_t hasFragmentPos = aUri.FindChar('#');
|
||||
int32_t hasQueryPos = aUri.FindChar('?');
|
||||
|
||||
int32_t pos = -1;
|
||||
if (hasFragmentPos >= 0 && hasQueryPos >= 0) {
|
||||
pos = std::min(hasFragmentPos, hasQueryPos);
|
||||
} else if (hasFragmentPos >= 0) {
|
||||
pos = hasFragmentPos;
|
||||
} else {
|
||||
pos = hasQueryPos;
|
||||
}
|
||||
else {
|
||||
uriIgnoringRef = StringHead(aUri, hashPos);
|
||||
|
||||
if (pos < 0) {
|
||||
gDataTable->Get(aUri, &res);
|
||||
} else {
|
||||
gDataTable->Get(StringHead(aUri, pos), &res);
|
||||
}
|
||||
gDataTable->Get(uriIgnoringRef, &res);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -383,6 +383,7 @@ skip-if = buildapp == 'b2g' || (android_version == '18' && debug) # b2g(flaky on
|
|||
support-files = test_XHR_timeout.js
|
||||
[test_base.xhtml]
|
||||
[test_blobconstructor.html]
|
||||
[test_blob_fragment_and_query.html]
|
||||
[test_bug166235.html]
|
||||
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # b2g(clipboard undefined) b2g-debug(clipboard undefined) b2g-desktop(clipboard undefined)
|
||||
[test_bug199959.html]
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Blob URI with fragments</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
var blob = new Blob(['hello world']);
|
||||
ok(blob, "We have a blob.");
|
||||
|
||||
var url = URL.createObjectURL(blob);
|
||||
ok(url, "We have a URI");
|
||||
|
||||
var tests = [
|
||||
url,
|
||||
url + "?aa",
|
||||
url + "#bb",
|
||||
url + "?cc#dd",
|
||||
url + "#ee?ff",
|
||||
];
|
||||
|
||||
function runTest() {
|
||||
if (!tests.length) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var test = tests.shift();
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', test);
|
||||
xhr.onload = function() {
|
||||
is(xhr.responseText, 'hello world', 'URL: ' + test);
|
||||
runTest();
|
||||
}
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runTest();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче