Bug 407303: only check JAR loads for unsafe content types if the underlying load completed successfully. r+sr=bz, blocking1.9=schrep

This commit is contained in:
dcamp%mozilla.com 2007-12-13 22:34:14 +00:00
Родитель fb9ffb54b2
Коммит 8e0f93d5f2
2 изменённых файлов: 48 добавлений и 8 удалений

Просмотреть файл

@ -724,11 +724,8 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
{ {
nsresult rv; nsresult rv;
// Grab the security info from our base channel
nsCOMPtr<nsIChannel> channel(do_QueryInterface(request)); nsCOMPtr<nsIChannel> channel(do_QueryInterface(request));
if (channel) { if (channel) {
channel->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
PRUint32 loadFlags; PRUint32 loadFlags;
channel->GetLoadFlags(&loadFlags); channel->GetLoadFlags(&loadFlags);
if (loadFlags & LOAD_REPLACE) { if (loadFlags & LOAD_REPLACE) {
@ -748,8 +745,15 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
mJarURI = newURI; mJarURI = newURI;
} }
} }
if (NS_SUCCEEDED(status)) {
status = rv; status = rv;
} }
}
}
if (NS_SUCCEEDED(status) && channel) {
// Grab the security info from our base channel
channel->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
if (httpChannel) { if (httpChannel) {
@ -774,12 +778,9 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
mIsUnsafe = unsafe; mIsUnsafe = unsafe;
} }
} }
// XXX: THIS IS TEMPORARY
//mIsUnsafe = PR_FALSE;
} }
if (mIsUnsafe) { if (NS_SUCCEEDED(status) && mIsUnsafe) {
PRBool allowUnpack = PR_FALSE; PRBool allowUnpack = PR_FALSE;
nsCOMPtr<nsIPrefBranch> prefs = nsCOMPtr<nsIPrefBranch> prefs =

Просмотреть файл

@ -0,0 +1,39 @@
// Regression test for bug 407303 - A failed channel should not be checked
// for an unsafe content type.
const Cc = Components.classes;
const Ci = Components.interfaces;
// XXX: NS_ERROR_UNKNOWN_HOST is not in Components.results
const NS_ERROR_UNKNOWN_HOST = 0x804B001E;
var listener = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIRequestObserver))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
onStartRequest: function(request, context) {
},
onDataAvailable: function(request, context, stream, offset, count) {
do_throw("shouldn't get data!");
},
onStopRequest: function(request, context, status) {
do_check_eq(status, NS_ERROR_UNKNOWN_HOST);
do_test_finished();
}
};
function run_test() {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var channel = ios.newChannel("jar:http://test.invalid/test.jar!/index.html",
null, null);
channel.asyncOpen(listener, null);
do_test_pending();
}