Bug 197379 - take2. Take 1 allowed file:// URLs with HFS paths to work. It did not work, though, when the volume name contained an escaped character. This patch unescapes the volume name before comparison. r=dougt/sr=darin

git-svn-id: svn://10.0.0.236/trunk@144216 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ccarlen%netscape.com
2003-06-27 14:31:38 +00:00
parent 3c2fed7e4a
commit aa4f765112

View File

@@ -48,8 +48,8 @@
static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPathComponent) static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPathComponent)
{ {
// Return whether the 1st path component in the given path is equal to the name // Return whether the 1st path component in path (escaped) is equal to the name
// of a mounted volume. Return the 1st path component in any case. // of a mounted volume. Return the 1st path component (unescaped) in any case.
// This needs to be done as quickly as possible, so we cache a list of volume names. // This needs to be done as quickly as possible, so we cache a list of volume names.
// XXX Register an event handler to detect drives being mounted/unmounted? // XXX Register an event handler to detect drives being mounted/unmounted?
@@ -82,8 +82,10 @@ static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPat
nsACString::const_iterator component_end(start); nsACString::const_iterator component_end(start);
FindCharInReadable('/', component_end, directory_end); FindCharInReadable('/', component_end, directory_end);
firstPathComponent = Substring(start, component_end); nsCAutoString flatComponent((Substring(start, component_end)));
PRInt32 foundIndex = gVolumeList.IndexOf(nsCAutoString(firstPathComponent)); NS_UnescapeURL(flatComponent);
PRInt32 foundIndex = gVolumeList.IndexOf(flatComponent);
firstPathComponent = flatComponent;
return (foundIndex != -1); return (foundIndex != -1);
} }
@@ -192,6 +194,8 @@ net_GetFileFromURLSpec(const nsACString &aURL, nsIFile **result)
return rv; return rv;
if (!directory.IsEmpty()) { if (!directory.IsEmpty()) {
NS_EscapeURL(directory, esc_Directory|esc_AlwaysCopy, path);
// The canonical form of file URLs on OSX use POSIX paths: // The canonical form of file URLs on OSX use POSIX paths:
// file:///path-name. // file:///path-name.
// But, we still encounter file URLs that use HFS paths: // But, we still encounter file URLs that use HFS paths:
@@ -209,8 +213,6 @@ net_GetFileFromURLSpec(const nsACString &aURL, nsIFile **result)
bHFSPath = PR_TRUE; bHFSPath = PR_TRUE;
} }
NS_EscapeURL(directory, esc_Directory|esc_AlwaysCopy, path);
if (bHFSPath) { if (bHFSPath) {
// "%2F"s need to become slashes, while all other slashes need to // "%2F"s need to become slashes, while all other slashes need to
// become colons. If we start out by changing "%2F"s to colons, we // become colons. If we start out by changing "%2F"s to colons, we