Fixing orange from bug 402983. Make file:///foo and file:////foo#bar compare as equal URLs. r+sr=bzbarsky@mit.edu

This commit is contained in:
jst%mozilla.org 2008-03-21 06:01:55 +00:00
Родитель 9d60cec0c4
Коммит f2a32b3bb6
1 изменённых файлов: 18 добавлений и 4 удалений

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

@ -319,10 +319,24 @@ nsScriptSecurityManager::SecurityCompareURIs(nsIURI* aSourceURI,
if (!sStrictFileOriginPolicy) if (!sStrictFileOriginPolicy)
return PR_TRUE; return PR_TRUE;
// Otherwise they had better match nsCOMPtr<nsIFileURL> sourceFileURL(do_QueryInterface(sourceBaseURI));
PRBool filesAreEqual = PR_FALSE; nsCOMPtr<nsIFileURL> targetFileURL(do_QueryInterface(targetBaseURI));
nsresult rv = sourceBaseURI->Equals(targetBaseURI, &filesAreEqual);
return NS_SUCCEEDED(rv) && filesAreEqual; if (!sourceFileURL || !targetFileURL)
return PR_FALSE;
nsCOMPtr<nsIFile> sourceFile, targetFile;
sourceFileURL->GetFile(getter_AddRefs(sourceFile));
targetFileURL->GetFile(getter_AddRefs(targetFile));
if (!sourceFile || !targetFile)
return PR_FALSE;
// Otherwise they had better match
PRBool filesAreEqual = PR_FALSE;
nsresult rv = sourceFile->Equals(targetFile, &filesAreEqual);
return NS_SUCCEEDED(rv) && filesAreEqual;
} }
// Special handling for mailnews schemes // Special handling for mailnews schemes