Make setting innerHTML in XHTML not crash on malformed content and throw an
exception instead. Bug 272011, patch by steve.swanson@mackichan.com, r+sr=bzbarsky
This commit is contained in:
@@ -1338,15 +1338,6 @@ nsXMLContentSink::HandleXMLDeclaration(const PRUnichar *aData,
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::ReportError(const PRUnichar* aErrorText,
|
||||
const PRUnichar* aSourceText)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mDocument));
|
||||
return ReportErrorFrom( aErrorText, aSourceText, node );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::ReportErrorFrom(const PRUnichar* aErrorText,
|
||||
const PRUnichar* aSourceText,
|
||||
nsIDOMNode* aNode)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@@ -1360,13 +1351,14 @@ nsXMLContentSink::ReportErrorFrom(const PRUnichar* aErrorText,
|
||||
|
||||
// Clear the current content and
|
||||
// prepare to set <parsererror> as the document root
|
||||
if (aNode) {
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mDocument));
|
||||
if (node) {
|
||||
for (;;) {
|
||||
nsCOMPtr<nsIDOMNode> child, dummy;
|
||||
aNode->GetLastChild(getter_AddRefs(child));
|
||||
node->GetLastChild(getter_AddRefs(child));
|
||||
if (!child)
|
||||
break;
|
||||
aNode->RemoveChild(child, getter_AddRefs(dummy));
|
||||
node->RemoveChild(child, getter_AddRefs(dummy));
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(mDocElement);
|
||||
|
||||
Reference in New Issue
Block a user