forked from mirrors/gecko-dev
Bug 553121 - Use resource URIs instead of file URIs for DTDs, r+sr=jst
This commit is contained in:
parent
9a2d4853f0
commit
dc57b86c73
1 changed files with 13 additions and 37 deletions
|
|
@ -316,14 +316,12 @@ LookupCatalogData(const PRUnichar* aPublicID)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
// aCatalogData can be null. If not null, it provides a hook to additional
|
||||
// built-in knowledge on the resource that we are trying to load. Returns true
|
||||
// if the local DTD specified in the catalog data exists or if the filename
|
||||
// contained within the url exists in the special DTD directory. If either of
|
||||
// this exists, aResult is set to the file: url that points to the DTD file
|
||||
// found in the local DTD directory.
|
||||
static PRBool
|
||||
IsLoadableDTD(const nsCatalogData* aCatalogData, nsIURI* aDTD,
|
||||
// This function provides a resource URI to a local DTD
|
||||
// in resource://gre/res/dtd/ which may or may not exist.
|
||||
// If aCatalogData is provided, it is used to remap the
|
||||
// DTD instead of taking the filename from the URI.
|
||||
static void
|
||||
GetLocalDTDURI(const nsCatalogData* aCatalogData, nsIURI* aDTD,
|
||||
nsIURI** aResult)
|
||||
{
|
||||
NS_ASSERTION(aDTD, "Null parameter.");
|
||||
|
|
@ -341,41 +339,18 @@ IsLoadableDTD(const nsCatalogData* aCatalogData, nsIURI* aDTD,
|
|||
// special DTD directory and it will be picked.
|
||||
nsCOMPtr<nsIURL> dtdURL = do_QueryInterface(aDTD);
|
||||
if (!dtdURL) {
|
||||
return PR_FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
dtdURL->GetFileName(fileName);
|
||||
if (fileName.IsEmpty()) {
|
||||
return PR_FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> dtdPath;
|
||||
NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(dtdPath));
|
||||
if (!dtdPath) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILocalFile> lfile = do_QueryInterface(dtdPath);
|
||||
|
||||
// append res/dtd/<fileName>
|
||||
// can't do AppendRelativeNativePath("res/dtd/" + fileName)
|
||||
// as that won't work on all platforms.
|
||||
lfile->AppendNative(NS_LITERAL_CSTRING("res"));
|
||||
lfile->AppendNative(NS_LITERAL_CSTRING("dtd"));
|
||||
lfile->AppendNative(fileName);
|
||||
|
||||
PRBool exists;
|
||||
dtdPath->Exists(&exists);
|
||||
if (!exists) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// The DTD was found in the local DTD directory.
|
||||
// Set aDTD to a file: url pointing to the local DTD
|
||||
NS_NewFileURI(aResult, dtdPath);
|
||||
|
||||
return *aResult != nsnull;
|
||||
nsCAutoString respath("resource://gre/res/dtd/");
|
||||
respath += fileName;
|
||||
NS_NewURI(aResult, respath);
|
||||
}
|
||||
|
||||
/***************************** END CATALOG UTILS *****************************/
|
||||
|
|
@ -795,7 +770,8 @@ nsExpatDriver::OpenInputStreamFromExternalDTD(const PRUnichar* aFPIStr,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIURI> localURI;
|
||||
if (!IsLoadableDTD(mCatalogData, uri, getter_AddRefs(localURI))) {
|
||||
GetLocalDTDURI(mCatalogData, uri, getter_AddRefs(localURI));
|
||||
if (!localURI) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue