Commit bf85dfb9 authored by hyatt's avatar hyatt

Add two more error messages to the HTMLParser.

        Report when the </br> -> <br> quirk is triggered.

        Also report whenever the broken XML self-closing tag syntax is used on
        tags that can actually have an end tag (either optional or required).

        Reviewed by aroben

        * html/HTMLParser.cpp:
        (WebCore::HTMLParser::parseToken):
        * html/HTMLParserErrorCodes.cpp:
        (WebCore::htmlParserErrorMessageTemplate):
        * html/HTMLParserErrorCodes.h:
        (WebCore::):
        * html/HTMLTokenizer.cpp:
        (WebCore::HTMLTokenizer::parseTag):
        * html/HTMLTokenizer.h:
        (WebCore::Token::reset):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21723 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b2f346f1
2007-05-24 David Hyatt <hyatt@apple.com>
Add two more error messages to the HTMLParser.
Report when the </br> -> <br> quirk is triggered.
Also report whenever the broken XML self-closing tag syntax is used on
tags that can actually have an end tag (either optional or required).
Reviewed by aroben
* html/HTMLParser.cpp:
(WebCore::HTMLParser::parseToken):
* html/HTMLParserErrorCodes.cpp:
(WebCore::htmlParserErrorMessageTemplate):
* html/HTMLParserErrorCodes.h:
(WebCore::):
* html/HTMLTokenizer.cpp:
(WebCore::HTMLTokenizer::parseTag):
* html/HTMLTokenizer.h:
(WebCore::Token::reset):
2007-05-24 Sam Weinig <sam@webkit.org>
Reviewed by Anders.
......@@ -195,8 +195,10 @@ PassRefPtr<Node> HTMLParser::parseToken(Token* t)
}
// Apparently some sites use </br> instead of <br>. Be compatible with IE and Firefox and treat this like <br>.
if (t->isCloseTag(brTag) && document->inCompatMode())
if (t->isCloseTag(brTag) && document->inCompatMode()) {
reportError(MalformedBRError);
t->beginTag = true;
}
if (!t->beginTag) {
processCloseTag(t);
......@@ -238,6 +240,11 @@ PassRefPtr<Node> HTMLParser::parseToken(Token* t)
if (isHeaderTag(t->tagName))
// Do not allow two header tags to be nested if the intervening tags are inlines.
popNestedHeaderTag();
// If the node does not have a forbidden end tag requirement, and if the broken XML self-closing
// syntax was used, report an error.
if (t->brokenXMLStyle && e->endTagRequirement() != TagStatusForbidden)
reportError(IncorrectXMLSelfCloseError, &t->tagName);
}
if (!insertNode(n.get(), t->flat)) {
......
......@@ -42,7 +42,9 @@ const char* htmlParserErrorMessageTemplate(HTMLParserErrorCode errorCode)
"%tag1 is not allowed inside <caption>. Closing the <caption> and trying the insertion again.",
"<table> is not allowed inside %tag1. Closing the current <table> and inserting the new <table> as a sibling.",
"%tag1 is not allowed inside %tag2. Inserting %tag1 before the <table> instead.",
"%tag1 misplaced in <table>. Creating %tag2 and putting %tag1 inside it."
"%tag1 misplaced in <table>. Creating %tag2 and putting %tag1 inside it.",
"</br> encountered. Converting </br> into <br>.",
"XML self-closing tag syntax used on %tag1. The tag will not be closed."
};
if (errorCode >= MisplacedTablePartError && errorCode <= TablePartRequiredError)
......
......@@ -40,7 +40,9 @@ enum HTMLParserErrorCode {
MisplacedCaptionContentError,
MisplacedTableError,
StrayTableContentError,
TablePartRequiredError
TablePartRequiredError,
MalformedBRError,
IncorrectXMLSelfCloseError
};
const char* htmlParserErrorMessageTemplate(HTMLParserErrorCode);
......
......@@ -1020,11 +1020,13 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString &src, State state)
if (inViewSourceMode())
currToken.addViewSourceChar(curchar);
// This is a quirk (with a long sad history). We have to do this
// since widgets do <script src="foo.js"/> and expect the tag to close.
if (currToken.tagName == scriptTag && curchar == '/')
currToken.flat = true;
if (curchar == '/') {
// This is a quirk (with a long sad history). We have to do this
// since widgets do <script src="foo.js"/> and expect the tag to close.
if (currToken.tagName == scriptTag)
currToken.flat = true;
currToken.brokenXMLStyle = true;
}
src.advance(lineNoPtr);
}
break;
......
......@@ -52,7 +52,7 @@ class Node;
*/
class Token {
public:
Token() : beginTag(true), flat(false), m_sourceInfo(0) { }
Token() : beginTag(true), flat(false), brokenXMLStyle(false), m_sourceInfo(0) { }
~Token() { }
void addAttribute(Document*, AtomicString& attrName, const AtomicString& v, bool viewSourceMode);
......@@ -67,6 +67,7 @@ public:
tagName = nullAtom;
beginTag = true;
flat = false;
brokenXMLStyle = false;
if (m_sourceInfo)
m_sourceInfo->clear();
}
......@@ -78,6 +79,7 @@ public:
AtomicString tagName;
bool beginTag;
bool flat;
bool brokenXMLStyle;
OwnPtr<Vector<UChar> > m_sourceInfo;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment