Bug 173668 - InitWithNativePath crashes if given a URL which begins with a forward slash. It happens during URI fixup. r=sdagley/sr=jaggernaut

git-svn-id: svn://10.0.0.236/trunk@134695 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ccarlen%netscape.com
2002-12-03 15:51:25 +00:00
parent 205710a252
commit dc6239e350

View File

@@ -1220,6 +1220,13 @@ NS_IMETHODIMP nsLocalFile::InitWithNativePath(const nsACString& filePath)
// On 10.2, huge paths crash CFURLGetFSRef()
if (filePath.Length() > PATH_MAX)
return NS_ERROR_FILE_NAME_TOO_LONG;
// And, a path with consecutive '/'s which are not between
// nodes also crashes CFURLGetFSRef(). Consecutive '/'s which
// are between actual nodes are OK. So, convert consecutive
// '/'s to a single one.
nsCAutoString fixedPath;
fixedPath.Assign(filePath);
fixedPath.ReplaceSubstring("//", "/");
mNonExtantNodes.clear();
mIdentityDirty = PR_TRUE;
@@ -1227,7 +1234,7 @@ NS_IMETHODIMP nsLocalFile::InitWithNativePath(const nsACString& filePath)
CFStringRef pathAsCFString;
CFURLRef pathAsCFURL;
pathAsCFString = ::CFStringCreateWithCString(nsnull, PromiseFlatCString(filePath).get(), kCFStringEncodingUTF8);
pathAsCFString = ::CFStringCreateWithCString(nsnull, fixedPath.get(), kCFStringEncodingUTF8);
if (!pathAsCFString)
return NS_ERROR_FAILURE;
pathAsCFURL = ::CFURLCreateWithFileSystemPath(nsnull, pathAsCFString, kCFURLPOSIXPathStyle, PR_FALSE);