mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 488818 - Mark malformed scripts as malformed in HTML5 tree builder.
This commit is contained in:
parent
5f070d1f64
commit
194b899472
@ -2541,9 +2541,6 @@ nsHtml5Tokenizer::eof()
|
||||
goto eofloop_end;
|
||||
} else {
|
||||
|
||||
endTag = PR_TRUE;
|
||||
tagName = contentModelElement;
|
||||
emitCurrentTagToken(PR_FALSE);
|
||||
goto eofloop_end;
|
||||
}
|
||||
}
|
||||
@ -2554,37 +2551,27 @@ nsHtml5Tokenizer::eof()
|
||||
}
|
||||
case NS_HTML5TOKENIZER_TAG_NAME: {
|
||||
|
||||
tagName = strBufToElementNameString();
|
||||
emitCurrentTagToken(PR_FALSE);
|
||||
goto eofloop_end;
|
||||
}
|
||||
case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME:
|
||||
case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED:
|
||||
case NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG: {
|
||||
|
||||
emitCurrentTagToken(PR_FALSE);
|
||||
goto eofloop_end;
|
||||
}
|
||||
case NS_HTML5TOKENIZER_ATTRIBUTE_NAME: {
|
||||
|
||||
attributeNameComplete();
|
||||
addAttributeWithoutValue();
|
||||
emitCurrentTagToken(PR_FALSE);
|
||||
goto eofloop_end;
|
||||
}
|
||||
case NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME:
|
||||
case NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE: {
|
||||
|
||||
addAttributeWithoutValue();
|
||||
emitCurrentTagToken(PR_FALSE);
|
||||
goto eofloop_end;
|
||||
}
|
||||
case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED:
|
||||
case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED:
|
||||
case NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED: {
|
||||
|
||||
addAttributeWithValue();
|
||||
emitCurrentTagToken(PR_FALSE);
|
||||
goto eofloop_end;
|
||||
}
|
||||
case NS_HTML5TOKENIZER_BOGUS_COMMENT: {
|
||||
|
@ -427,7 +427,7 @@ nsHtml5TreeBuilder::eof()
|
||||
case NS_HTML5TREE_BUILDER_IN_FOREIGN: {
|
||||
|
||||
while (stack[currentPtr]->ns != kNameSpaceID_XHTML) {
|
||||
pop();
|
||||
popOnEof();
|
||||
}
|
||||
foreignFlag = NS_HTML5TREE_BUILDER_NOT_IN_FOREIGN;
|
||||
}
|
||||
@ -456,7 +456,7 @@ nsHtml5TreeBuilder::eof()
|
||||
|
||||
}
|
||||
while (currentPtr > 0) {
|
||||
pop();
|
||||
popOnEof();
|
||||
}
|
||||
mode = NS_HTML5TREE_BUILDER_AFTER_HEAD;
|
||||
continue;
|
||||
@ -464,7 +464,7 @@ nsHtml5TreeBuilder::eof()
|
||||
case NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT: {
|
||||
|
||||
while (currentPtr > 1) {
|
||||
pop();
|
||||
popOnEof();
|
||||
}
|
||||
mode = NS_HTML5TREE_BUILDER_IN_HEAD;
|
||||
continue;
|
||||
@ -479,7 +479,7 @@ nsHtml5TreeBuilder::eof()
|
||||
|
||||
goto eofloop_end;
|
||||
} else {
|
||||
pop();
|
||||
popOnEof();
|
||||
mode = NS_HTML5TREE_BUILDER_IN_TABLE;
|
||||
continue;
|
||||
}
|
||||
@ -493,9 +493,9 @@ nsHtml5TreeBuilder::eof()
|
||||
case NS_HTML5TREE_BUILDER_IN_CDATA_RCDATA: {
|
||||
|
||||
if (originalMode == NS_HTML5TREE_BUILDER_AFTER_HEAD) {
|
||||
pop();
|
||||
popOnEof();
|
||||
}
|
||||
pop();
|
||||
popOnEof();
|
||||
mode = originalMode;
|
||||
continue;
|
||||
}
|
||||
@ -521,10 +521,10 @@ nsHtml5TreeBuilder::eof()
|
||||
}
|
||||
eofloop_end: ;
|
||||
while (currentPtr > 0) {
|
||||
pop();
|
||||
popOnEof();
|
||||
}
|
||||
if (!fragment) {
|
||||
pop();
|
||||
popOnEof();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3263,6 +3263,18 @@ nsHtml5TreeBuilder::pop()
|
||||
node->release();
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::popOnEof()
|
||||
{
|
||||
flushCharacters();
|
||||
nsHtml5StackNode* node = stack[currentPtr];
|
||||
|
||||
currentPtr--;
|
||||
elementPopped(node->ns, node->popName, node->node);
|
||||
markMalformedIfScript(node->node);
|
||||
node->release();
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::appendHtmlElementToDocumentAndPush(nsHtml5HtmlAttributes* attributes)
|
||||
{
|
||||
|
@ -156,6 +156,7 @@ class nsHtml5TreeBuilder
|
||||
void insertIntoFosterParent(nsIContent* child);
|
||||
PRBool isInStack(nsHtml5StackNode* node);
|
||||
void pop();
|
||||
void popOnEof();
|
||||
void appendHtmlElementToDocumentAndPush(nsHtml5HtmlAttributes* attributes);
|
||||
void appendHtmlElementToDocumentAndPush();
|
||||
void appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes* attributes);
|
||||
@ -190,6 +191,7 @@ class nsHtml5TreeBuilder
|
||||
void appendComment(nsIContent* parent, PRUnichar* buf, PRInt32 start, PRInt32 length);
|
||||
void appendCommentToDocument(PRUnichar* buf, PRInt32 start, PRInt32 length);
|
||||
void addAttributesToElement(nsIContent* element, nsHtml5HtmlAttributes* attributes);
|
||||
void markMalformedIfScript(nsIContent* elt);
|
||||
void start(PRBool fragment);
|
||||
void end();
|
||||
void appendDoctypeToDocument(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier);
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsIScriptElement.h"
|
||||
|
||||
#define NS_HTML5_TREE_BUILDER_MAX_QUEUE_TIME 3000000UL // microseconds
|
||||
#define NS_HTML5_TREE_BUILDER_DEFAULT_QUEUE_LENGTH 200
|
||||
@ -246,6 +247,16 @@ nsHtml5TreeBuilder::addAttributesToElement(nsIContent* aElement, nsHtml5HtmlAttr
|
||||
treeOp->Init(eTreeOpAddAttributes, holder, aElement);
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::markMalformedIfScript(nsIContent* elt)
|
||||
{
|
||||
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(elt);
|
||||
if (sele) {
|
||||
// Make sure to serialize this script correctly, for nice round tripping.
|
||||
sele->SetIsMalformed();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeBuilder::start(PRBool fragment)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user