From ca3fa1fe62a35e773389a0ab732e646d8f46c58a Mon Sep 17 00:00:00 2001 From: Ivan Nikulin Date: Sun, 10 Dec 2017 19:50:27 +0000 Subject: [PATCH] Parse errors for a bunch of insertion modes with a word "head" in them (#22) * Add misplaced-doctype error in before head mode * Add end-tag-without-matching-open-element error in before head mode * Add in head insertion mode errors * Add in head noscript insertion mode errors * Add after head insertion mode errors * Add exceptions for end-tag-without-matching-open-element error. Limit scope of noscript error to * Add missing article * Nits in abandoned-head-element-child error description * Clarify misplaced-start-tag-for-head-element * Process head in noscript in head using rules for head * nested-noscript-in-head error --- source | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 138 insertions(+), 16 deletions(-) diff --git a/source b/source index d028c33bba9..dba6d80880c 100644 --- a/source +++ b/source @@ -99858,6 +99858,32 @@ dictionary StorageEventInit : EventInit { Code Description + + abandoned-head-element-child +

This error occurs if the parser encounters a start + tag for an element that is allowed by the parsing rules to be a head + element's child, but placed between the head element's + end tag and the body element's start tag or + any content that opens the body element if it's start tag is omitted. The parser treats such elements as child elements + of the head element.

+ +
+

For example, consider the following markup:

+ +
<!DOCTYPE html>
+<html>
+ <head></head>
+ <title>The Answer</title>
+ <script src="foo.js"></script>
+ <body></body>
+</html>
+ +

This will be parsed into:

+ + +
+ abrupt-closing-of-empty-comment

This error occurs if the parser encounters an empty StorageEventInit : EventInit { that is greater than the valid Unicode range. The parser resolves such a character reference to a U+FFFD REPLACEMENT CHARACTER.

+ + closing-of-element-with-open-child-elements +

This error occurs if the parser encounters an end + tag for an element that has open child elements for which end tag can not be omitted (e.g., <template><div></template>). In this case the parser closes such + child elements implicitly.

+ control-character-in-input-stream

This error occurs if the input stream contains a StorageEventInit : EventInit { references as-is except C1 control references that are replaced according to the numeric character reference end state.

+ + disallowed-content-in-noscript-in-head +

This error occurs if the parser encounters any content other than ASCII + whitespace, comments, a basefont + element, a bgsound element, a link element, a meta + element, a noframes element, or a style element in a + noscript element in the head. In this case, the parser implicitly + closes the noscript element and processes the content as if it was placed after + the noscript element in the markup.

+ duplicate-attribute

This error occurs if the parser encounters an attribute in a tag that already has an attribute with the - same name. The parser ignores all such duplicate occurrences of the attribute. + same name. The parser ignores all such duplicate occurrences of the attribute.

+ + + misplaced-start-tag-for-head-element +

This error occurs if the parser encounters a start + tag whose tag name is "head" inside or after the existing head element. + The parser ignores such start tags.

+ +

Some content opens the head element implicitly. Therefore, a start + tag for the head that appear after such content will trigger this error, even + though there were no start tags for head present in markup before.

end-tag-with-attributes @@ -99937,6 +99991,16 @@ dictionary StorageEventInit : EventInit { code point (e.g., </div/>). Such a tag is treated as a regular end tag.

+ + end-tag-without-matching-open-element +

This error occurs if the parser encounters an end + tag whose tag name is not "br" or "p" and that doesn't match any open element. The + parser ignores such end tags.

+ +

The parser can implicitly create open elements even if the markup doesn't + contain start tags for them (e.g., for an + html element).

+ eof-before-tag-name

This error occurs if the parser encounters the end of the input stream @@ -100037,6 +100101,13 @@ dictionary StorageEventInit : EventInit { alpha, a wide range of code points (including ASCII digits) is allowed in subsequent positions.

+ + misplaced-doctype +

This error occurs if the parser encounters a DOCTYPE that is not a document preamble, i.e. it is preceded + with a content other than comments or ASCII + whitespace. The parser ignores such DOCTYPEs.

+ missing-attribute-value

This error occurs if the parser encounters a U+003E (>) code point where an @@ -100154,6 +100225,12 @@ dictionary StorageEventInit : EventInit { -->). Such a comment will be closed by the first occuring "-->" code point sequence and everything that follows will be treated as markup.

+ + nested-noscript-in-head +

This error occurs if the parser encounters a start + tag whose tag name is "noscript" in a noscript element in the + head. The parser ignores such start tags.

+ non-conforming-doctype

This error occurs if the parser encounters the StorageEventInit : EventInit { point. The parser resolves such character references to a U+FFFD REPLACEMENT CHARACTER.

+ + open-elements-left-after-eof +

This error occurs if the parser encounters the end of the input stream, + whereas there are open elements for which end tag can not + be omitted (e.g., <!DOCTYPE html><div>). In this case the parser closes such elements + implicitly.

+ surrogate-character-reference

This error occurs if the parser encounters a numeric A DOCTYPE token

-

Parse error. Ignore the token.

+

This is a misplaced-doctype parse + error. Ignore the token.

A start tag whose tag name is "html"
@@ -105337,7 +105423,9 @@ document.body.appendChild(text);
Any other end tag
-

Parse error. Ignore the token.

+

This is an end-tag-without-matching-open-element + parse error. Ignore the token.

@@ -105384,7 +105472,8 @@ document.body.appendChild(text);
A DOCTYPE token
-

Parse error. Ignore the token.

+

This is a misplaced-doctype parse + error. Ignore the token.

A start tag whose tag name is "html"
@@ -105548,7 +105637,9 @@ document.body.appendChild(text);

If there is no template element on the stack of open elements, then - this is a parse error; ignore the token.

+ this is an end-tag-without-matching-open-element + parse error; ignore the token.

Otherwise, run these steps:

@@ -105557,6 +105648,8 @@ document.body.appendChild(text);
  • Generate all implied end tags thoroughly.

  • If the current node is not a template element, then this is a + closing-of-element-with-open-child-elements parse error.

  • Pop elements from the stack of open elements until a template @@ -105574,9 +105667,17 @@ document.body.appendChild(text);

  • A start tag whose tag name is "head"
    +
    +

    This is a misplaced-start-tag-for-head-element + parse error. Ignore the token.

    +
    +
    Any other end tag
    -

    Parse error. Ignore the token.

    +

    This is an end-tag-without-matching-open-element + parse error. Ignore the token.

    Anything else
    @@ -105609,7 +105710,8 @@ document.body.appendChild(text);
    A DOCTYPE token
    -

    Parse error. Ignore the token.

    +

    This is a misplaced-doctype parse + error. Ignore the token.

    A start tag whose tag name is "html"
    @@ -105620,6 +105722,10 @@ document.body.appendChild(text); +
    A start tag whose tag name is "noscript"
    +
    This is a nested-noscript-in-head + parse error. Ignore the token.
    +
    An end tag whose tag name is "noscript"
    @@ -105635,8 +105741,8 @@ document.body.appendChild(text);
    A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE
    A comment token
    -
    A start tag whose tag name is one of: "basefont", "bgsound", "link", "meta", "noframes", - "style"
    +
    A start tag whose tag name is one of: "basefont", "bgsound", "head", "link", "meta", + "noframes", "style"

    Process the token using the rules for the "

    -
    A start tag whose tag name is one of: "head", "noscript"
    Any other end tag
    -

    Parse error. Ignore the token.

    +

    This is an end-tag-without-matching-open-element + parse error. Ignore the token.

    Anything else
    - + -

    Parse error.

    +

    If the token is an end-of-file token then this is an open-elements-left-after-eof + parse error, otherwise this is a disallowed-content-in-noscript-in-head + parse error.

    Pop the current node (which will be a noscript element) from the @@ -105700,7 +105811,8 @@ document.body.appendChild(text);

    A DOCTYPE token
    -

    Parse error. Ignore the token.

    +

    This is a misplaced-doctype parse + error. Ignore the token.

    A start tag whose tag name is "html"
    @@ -105737,7 +105849,9 @@ document.body.appendChild(text); "noframes", "script", "style", "template", "title"
    -

    Parse error.

    +

    This is an abandoned-head-element-child + parse error.

    Push the node pointed to by the head element pointer onto the stack of open elements.

    @@ -105766,9 +105880,17 @@ document.body.appendChild(text);
    A start tag whose tag name is "head"
    +
    +

    This is a misplaced-start-tag-for-head-element + parse error. Ignore the token.

    +
    +
    Any other end tag
    -

    Parse error. Ignore the token.

    +

    This is an end-tag-without-matching-open-element + parse error. Ignore the token.

    Anything else