Bug 420609 - "XMLHttpRequest no longer able to parse XHTML documents with entity references" [p=trev.moz@adblockplus.org (Wladimir Palant) r+sr=bzbarsky a1.9=sicking a=blocking1.9+]

This commit is contained in:
reed@reedloden.com 2008-03-05 02:29:32 -08:00
parent 786059e5f5
commit 419bed8306
8 changed files with 48 additions and 5 deletions

View File

@ -139,6 +139,7 @@ NS_CP_ContentTypeName(PRUint32 contentType)
CASE_RETURN( TYPE_PING );
CASE_RETURN( TYPE_XMLHTTPREQUEST );
CASE_RETURN( TYPE_OBJECT_SUBREQUEST );
CASE_RETURN( TYPE_DTD );
default:
return "<Unknown Type>";
}

View File

@ -51,7 +51,7 @@ interface nsIDOMNode;
* by launching a dialog to prompt the user for something).
*/
[scriptable,uuid(a32a984a-7a6b-ea92-75fe-1166be801a0e)]
[scriptable,uuid(58cf9dca-40b3-6211-a508-7351f437a53e)]
interface nsIContentPolicy : nsISupports
{
const unsigned long TYPE_OTHER = 1;
@ -121,6 +121,11 @@ interface nsIContentPolicy : nsISupports
*/
const unsigned long TYPE_OBJECT_SUBREQUEST = 12;
/**
* Indicates a DTD loaded by an XML document.
*/
const unsigned long TYPE_DTD = 13;
//////////////////////////////////////////////////////////////////////
/**

View File

@ -72,7 +72,7 @@ nsDataDocumentContentPolicy::ShouldLoad(PRUint32 aContentType,
doc = do_QueryInterface(domDoc);
}
}
if (doc && doc->IsLoadedAsData()) {
if (aContentType != nsIContentPolicy::TYPE_DTD && doc && doc->IsLoadedAsData()) {
*aDecision = nsIContentPolicy::REJECT_TYPE;
}

View File

@ -174,6 +174,7 @@ _TEST_FILES = test_bug5141.html \
test_bug417255.html \
test_bug417384.html \
test_bug418214.html \
test_bug420609.xhtml \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -0,0 +1,35 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=420609
-->
<head>
<title>Test for Bug 420609</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=420609">Mozilla Bug 420609</a>
<p id="display"></p>
<div id="content" style="display: none">
&nbsp;&mdash;&sup1;&hellip;
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[
/** Test for Bug 420609 **/
var request = new XMLHttpRequest();
request.open("GET", window.location.href, false);
request.send(null);
ok(request.responseXML && request.responseXML.documentElement.tagName == "html", "XMLHttpRequest should load XHTML document with entities");
is(document.getElementById("content").textContent, request.responseXML.getElementById("content").textContent, "Entities should be expanded in the document loaded by XMLHttpRequest");
]]>
</script>
</pre>
</body>
</html>

View File

@ -64,7 +64,8 @@ static const char *kTypeString[NUMBER_OF_TYPES] = {"other",
"xbl",
"ping",
"xmlhttprequest",
"objectsubrequest"};
"objectsubrequest",
"dtd"};
NS_IMPL_ISUPPORTS3(nsContentBlocker,

View File

@ -47,7 +47,7 @@ class nsIPrefBranch;
////////////////////////////////////////////////////////////////////////////////
// number of permission types in nsIContentPolicy
#define NUMBER_OF_TYPES 12
#define NUMBER_OF_TYPES 13
class nsContentBlocker : public nsIContentPolicy,
public nsIObserver,

View File

@ -804,7 +804,7 @@ nsExpatDriver::OpenInputStreamFromExternalDTD(const PRUnichar* aFPIStr,
if (sink)
doc = do_QueryInterface(sink->GetTarget());
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OTHER,
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_DTD,
uri,
(doc ? doc->NodePrincipal() : nsnull),
doc,