]> Cypherpunks repositories - gostls13.git/commitdiff
html: correctly parse </html> in <head> element.
authorAndrew Balholm <andybalholm@gmail.com>
Wed, 9 Nov 2011 08:18:26 +0000 (19:18 +1100)
committerNigel Tao <nigeltao@golang.org>
Wed, 9 Nov 2011 08:18:26 +0000 (19:18 +1100)
Pass tests1.dat, test 92:
<head></html><meta><p>

| <html>
|   <head>
|   <body>
|     <meta>
|     <p>

Also pass tests through test 98:
<p><b><div><marquee></p></b></div>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5359054

src/pkg/html/parse.go
src/pkg/html/parse_test.go

index f47d4ea147cb2f6ac1a3f08498f88b44c5c9c284..c64eb66fcbd1de7600718e2e4f38dcc2249a958c 100644 (file)
@@ -470,10 +470,15 @@ func inHeadIM(p *parser) (insertionMode, bool) {
                        implied = true
                }
        case EndTagToken:
-               if p.tok.Data == "head" {
+               switch p.tok.Data {
+               case "head":
                        pop = true
+               case "body", "html", "br":
+                       implied = true
+               default:
+                       // Ignore the token.
+                       return inHeadIM, true
                }
-               // TODO.
        case CommentToken:
                p.addChild(&Node{
                        Type: CommentNode,
@@ -524,7 +529,14 @@ func afterHeadIM(p *parser) (insertionMode, bool) {
                        framesetOK = true
                }
        case EndTagToken:
-               // TODO.
+               switch p.tok.Data {
+               case "body", "html", "br":
+                       implied = true
+                       framesetOK = true
+               default:
+                       // Ignore the token.
+                       return afterHeadIM, true
+               }
        case CommentToken:
                p.addChild(&Node{
                        Type: CommentNode,
index 27979225b332a5202dd5159a5f5dadd392158c8e..14863da79f602c4e8215ec3694619dd5c7f5bd0f 100644 (file)
@@ -133,7 +133,7 @@ func TestParser(t *testing.T) {
                n int
        }{
                // TODO(nigeltao): Process all the test cases from all the .dat files.
-               {"tests1.dat", 92},
+               {"tests1.dat", 99},
                {"tests2.dat", 0},
                {"tests3.dat", 0},
        }