From 7a9b183603562a6bf5c3b99f084b50951eb81db4 Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Wed, 23 Nov 2005 20:35:37 +0000 Subject: [PATCH] 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 --- mozilla/modules/libjar/nsIJARURI.idl | 8 ++++---- mozilla/modules/libjar/nsJARChannel.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mozilla/modules/libjar/nsIJARURI.idl b/mozilla/modules/libjar/nsIJARURI.idl index a2a84a06dcd..ed78aff8da6 100644 --- a/mozilla/modules/libjar/nsIJARURI.idl +++ b/mozilla/modules/libjar/nsIJARURI.idl @@ -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; }; diff --git a/mozilla/modules/libjar/nsJARChannel.cpp b/mozilla/modules/libjar/nsJARChannel.cpp index f3b1c882c15..7bba2b99092 100644 --- a/mozilla/modules/libjar/nsJARChannel.cpp +++ b/mozilla/modules/libjar/nsJARChannel.cpp @@ -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 fileURL = do_QueryInterface(mJarBaseURI);