Bug 418119 - "nsIContentPolicy not called for external DTDs of XML documents" [p=trev.moz@adblockplus.org (Wladimir Palant) r=sicking sr=peterv a1.9=beltzner a=blocking1.9+]

git-svn-id: svn://10.0.0.236/trunk@246302 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
reed%reedloden.com
2008-02-22 11:32:24 +00:00
parent 408a56a7bd
commit 0191864e90
2 changed files with 25 additions and 0 deletions

View File

@@ -66,6 +66,10 @@ REQUIRES = xpcom \
nkcache \
intl \
xpconnect \
layout \
widget \
caps \
js \
$(NULL)
SHARED_LIBRARY_LIBS = \

View File

@@ -56,6 +56,9 @@
#include "nsCRT.h"
#include "nsIConsoleService.h"
#include "nsIScriptError.h"
#include "nsIContentPolicy.h"
#include "nsContentPolicyUtils.h"
#include "nsContentErrors.h"
#include "nsXPCOMCIDInternal.h"
#include "nsUnicharInputStream.h"
@@ -796,6 +799,24 @@ nsExpatDriver::OpenInputStreamFromExternalDTD(const PRUnichar* aFPIStr,
localURI.swap(uri);
}
nsCOMPtr<nsIContentSink> sink = do_QueryInterface(mSink);
nsCOMPtr<nsIDocument> doc;
if (sink)
doc = do_QueryInterface(sink->GetTarget());
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OTHER,
uri,
(doc ? doc->NodePrincipal() : nsnull),
doc,
EmptyCString(), //mime guess
nsnull, //extra
&shouldLoad);
if (NS_FAILED(rv)) return rv;
if (NS_CP_REJECTED(shouldLoad)) {
// Disallowed by content policy
return NS_ERROR_CONTENT_BLOCKED;
}
rv = NS_OpenURI(aStream, uri);
nsCAutoString absURL;