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+]

This commit is contained in:
reed@reedloden.com 2008-02-22 03:32:24 -08:00
parent d2d865f581
commit 374700b955
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;