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

This commit is contained in:
darin%meer.net 2005-11-23 20:35:37 +00:00
Родитель a8cdc34752
Коммит e33d64b3dc
2 изменённых файлов: 11 добавлений и 4 удалений

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

@ -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;
};

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

@ -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);