From 9a33ca8346ffc1737bef26e1e04596309ac7aa39 Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Wed, 7 Jun 2000 09:07:10 +0000 Subject: [PATCH] Fixed jar url resolve so that chrome protocol works. Fixed jar channel to not remove channel after kicking off load. Bug 18433 git-svn-id: svn://10.0.0.236/trunk@71713 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libjar/nsJARChannel.cpp | 2 +- mozilla/modules/libjar/nsJARURI.cpp | 15 ++++++++++++++- mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp | 2 +- mozilla/netwerk/protocol/jar/src/nsJARURI.cpp | 15 ++++++++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/mozilla/modules/libjar/nsJARChannel.cpp b/mozilla/modules/libjar/nsJARChannel.cpp index f3f813eb893..ee2244b5e6a 100644 --- a/mozilla/modules/libjar/nsJARChannel.cpp +++ b/mozilla/modules/libjar/nsJARChannel.cpp @@ -534,7 +534,7 @@ nsJARChannel::EnsureJARFileAvailable(OnJARFileAvailableFun onJARFileAvailable, } error: - if (mLoadGroup) { + if (NS_FAILED(rv) && mLoadGroup) { nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, rv, nsnull); // XXX fix error message NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); } diff --git a/mozilla/modules/libjar/nsJARURI.cpp b/mozilla/modules/libjar/nsJARURI.cpp index 89112c2a091..98e8fb74e41 100644 --- a/mozilla/modules/libjar/nsJARURI.cpp +++ b/mozilla/modules/libjar/nsJARURI.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -296,9 +296,22 @@ NS_IMETHODIMP nsJARURI::Resolve(const char *relativePath, char **result) { nsresult rv; + + if (!relativePath) return NS_ERROR_NULL_POINTER; + NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv); if (NS_FAILED(rv)) return rv; + nsXPIDLCString scheme; + rv = serv->ExtractScheme(relativePath, nsnull, nsnull, getter_Copies(scheme)); + if (NS_SUCCEEDED(rv)) { + // then aSpec is absolute + *result = nsCRT::strdup(relativePath); + if (*result == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; + } + nsCAutoString path(mJAREntry); PRInt32 pos = path.RFind("/"); if (pos >= 0) diff --git a/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp b/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp index f3f813eb893..ee2244b5e6a 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp @@ -534,7 +534,7 @@ nsJARChannel::EnsureJARFileAvailable(OnJARFileAvailableFun onJARFileAvailable, } error: - if (mLoadGroup) { + if (NS_FAILED(rv) && mLoadGroup) { nsresult rv2 = mLoadGroup->RemoveChannel(this, nsnull, rv, nsnull); // XXX fix error message NS_ASSERTION(NS_SUCCEEDED(rv2), "RemoveChannel failed"); } diff --git a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp index 89112c2a091..98e8fb74e41 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -296,9 +296,22 @@ NS_IMETHODIMP nsJARURI::Resolve(const char *relativePath, char **result) { nsresult rv; + + if (!relativePath) return NS_ERROR_NULL_POINTER; + NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv); if (NS_FAILED(rv)) return rv; + nsXPIDLCString scheme; + rv = serv->ExtractScheme(relativePath, nsnull, nsnull, getter_Copies(scheme)); + if (NS_SUCCEEDED(rv)) { + // then aSpec is absolute + *result = nsCRT::strdup(relativePath); + if (*result == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; + } + nsCAutoString path(mJAREntry); PRInt32 pos = path.RFind("/"); if (pos >= 0)