зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1415574 - make nsJARURI::SetSpecWithBase ignore URL string; r=bagder
MozReview-Commit-ID: 9090OAAP7QD --HG-- extra : rebase_source : 072899eb53a2a868d5f64434d5ebc7e61ab4cc90
This commit is contained in:
Родитель
3e46ee7dc9
Коммит
5529423401
|
@ -326,12 +326,18 @@ nsJARURI::SetSpecWithBase(const nsACString &aSpec, nsIURI* aBaseURL)
|
||||||
|
|
||||||
++begin; // now we're past the "jar:"
|
++begin; // now we're past the "jar:"
|
||||||
|
|
||||||
|
nsACString::const_iterator delim_begin = begin;
|
||||||
|
nsACString::const_iterator delim_end = end;
|
||||||
nsACString::const_iterator frag = begin;
|
nsACString::const_iterator frag = begin;
|
||||||
while (frag != end && *frag != '#') {
|
|
||||||
|
if (FindInReadable(NS_JAR_DELIMITER, delim_begin, delim_end)) {
|
||||||
|
frag = delim_end;
|
||||||
|
}
|
||||||
|
while (frag != end && (*frag != '#' && *frag != '?')) {
|
||||||
++frag;
|
++frag;
|
||||||
}
|
}
|
||||||
if (frag != end) {
|
if (frag != end) {
|
||||||
// there was a fragment, mark that as the end of the URL to scan
|
// there was a fragment or query, mark that as the end of the URL to scan
|
||||||
end = frag;
|
end = frag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,11 +349,12 @@ nsJARURI::SetSpecWithBase(const nsACString &aSpec, nsIURI* aBaseURL)
|
||||||
// Also, the outermost "inner" URI may be a relative URI:
|
// Also, the outermost "inner" URI may be a relative URI:
|
||||||
// jar:../relative.jar!/a.html
|
// jar:../relative.jar!/a.html
|
||||||
|
|
||||||
nsACString::const_iterator delim_begin (begin),
|
delim_begin = begin;
|
||||||
delim_end (end);
|
delim_end = end;
|
||||||
|
|
||||||
if (!RFindInReadable(NS_JAR_DELIMITER, delim_begin, delim_end))
|
if (!RFindInReadable(NS_JAR_DELIMITER, delim_begin, delim_end)) {
|
||||||
return NS_ERROR_MALFORMED_URI;
|
return NS_ERROR_MALFORMED_URI;
|
||||||
|
}
|
||||||
|
|
||||||
rv = ioServ->NewURI(Substring(begin, delim_begin), mCharsetHint.get(),
|
rv = ioServ->NewURI(Substring(begin, delim_begin), mCharsetHint.get(),
|
||||||
aBaseURL, getter_AddRefs(mJARFile));
|
aBaseURL, getter_AddRefs(mJARFile));
|
||||||
|
|
|
@ -11,7 +11,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||||
|
|
||||||
// Check that reading non existant inner jars results in the right error
|
// Check that reading non existant inner jars results in the right error
|
||||||
|
|
||||||
function run_test() {
|
add_task(async function() {
|
||||||
var file = do_get_file("data/test_bug597702.zip");
|
var file = do_get_file("data/test_bug597702.zip");
|
||||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||||
getService(Ci.nsIIOService);
|
getService(Ci.nsIIOService);
|
||||||
|
@ -21,4 +21,28 @@ function run_test() {
|
||||||
var instr = goodChannel.open2();
|
var instr = goodChannel.open2();
|
||||||
|
|
||||||
ok(!!instr, "Should be able to open channel");
|
ok(!!instr, "Should be able to open channel");
|
||||||
}
|
});
|
||||||
|
|
||||||
|
add_task(async function() {
|
||||||
|
var file = do_get_file("data/test_bug597702.zip");
|
||||||
|
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||||
|
getService(Ci.nsIIOService);
|
||||||
|
var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
|
||||||
|
var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello?ignore%20this%20part!/";
|
||||||
|
var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
|
||||||
|
var instr = goodChannel.open2();
|
||||||
|
|
||||||
|
ok(!!instr, "Should be able to open channel");
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function() {
|
||||||
|
var file = do_get_file("data/test_bug597702.zip");
|
||||||
|
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||||
|
getService(Ci.nsIIOService);
|
||||||
|
var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
|
||||||
|
var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello?ignore#this!/part";
|
||||||
|
var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
|
||||||
|
var instr = goodChannel.open2();
|
||||||
|
|
||||||
|
ok(!!instr, "Should be able to open channel");
|
||||||
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче