]> Cypherpunks repositories - gostls13.git/commitdiff
exp/html: correctly handle <title> after </head>
authorAndrew Balholm <andybalholm@gmail.com>
Tue, 7 Aug 2012 03:36:08 +0000 (13:36 +1000)
committerNigel Tao <nigeltao@golang.org>
Tue, 7 Aug 2012 03:36:08 +0000 (13:36 +1000)
The <title> element was getting removed from the stack of open elements,
when its parent, the <head> element should have been removed instead.

Pass 2 additional tests.

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

src/pkg/exp/html/parse.go
src/pkg/exp/html/testlogs/tests7.dat.log

index 6b1f40cb8ea463ee4ef67b33cdd85f054cc51626..0bde2fe0e72cb70f47236400ddbc63bb042e335e 100644 (file)
@@ -669,7 +669,7 @@ func afterHeadIM(p *parser) bool {
                        return true
                case a.Base, a.Basefont, a.Bgsound, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Title:
                        p.oe = append(p.oe, p.head)
-                       defer p.oe.pop()
+                       defer p.oe.remove(p.head)
                        return inHeadIM(p)
                case a.Head:
                        // Ignore the token.
index 85d6c77088c71169ed8919f186a85f7624937234..dfb956b01f995e8c562d29e10b1658ab89b01f37 100644 (file)
@@ -1,7 +1,7 @@
 PASS "<!doctype html><body><title>X</title>"
 PASS "<!doctype html><table><title>X</title></table>"
-FAIL "<!doctype html><head></head><title>X</title>"
-FAIL "<!doctype html></head><title>X</title>"
+PASS "<!doctype html><head></head><title>X</title>"
+PASS "<!doctype html></head><title>X</title>"
 PASS "<!doctype html><table><meta></table>"
 PASS "<!doctype html><table>X<tr><td><table> <meta></table></table>"
 PASS "<!doctype html><html> <head>"