fixes bug 289851 "jar: protocol does not handle file names with embedded spaces" patch by Simo Melenius (simo.melenius@citec.fi), r=biesi, sr=darin

git-svn-id: svn://10.0.0.236/trunk@185213 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
darin%meer.net
2005-11-23 20:35:37 +00:00
parent 1cb5eb859c
commit 7a9b183603
2 changed files with 11 additions and 4 deletions

View File

@@ -51,14 +51,14 @@
interface nsIJARURI : nsIURL {
/**
* Returns the root URI (the one for the actual JAR file) for this JAR.
* eg http://www.big.com/blue.jar
* Returns the root URI (the one for the actual JAR file) for this JAR
* (e.g., http://www.big.com/blue.jar).
*/
attribute nsIURI JARFile;
/**
* Returns the entry specified for this JAR URI.
* eg ocean.html
* Returns the entry specified for this JAR URI (e.g., "ocean.html"). This
* value may contain %-escaped byte sequences.
*/
attribute AUTF8String JAREntry;
};

View File

@@ -41,6 +41,7 @@
#include "nsMimeTypes.h"
#include "nsNetUtil.h"
#include "nsInt64.h"
#include "nsEscape.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPrincipal.h"
@@ -280,6 +281,12 @@ nsJARChannel::EnsureJarInput(PRBool blocking)
rv = mJarURI->GetJAREntry(mJarEntry);
if (NS_FAILED(rv)) return rv;
// The name of the JAR entry must not contains URL escaped characters:
// we're moving from URL domain to a filename domain here. nsStandardURL
// does basic escaping by default, which breaks reading zipped files which
// have e.g. spaces in their filenames.
NS_UnescapeURL(mJarEntry);
// try to get a nsIFile directly from the url, which will often succeed.
{
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mJarBaseURI);