]> Cypherpunks repositories - gostls13.git/commitdiff
exp/html: ignore self-closing flag except in SVG and MathML
authorAndrew Balholm <andybalholm@gmail.com>
Thu, 9 Aug 2012 23:34:10 +0000 (09:34 +1000)
committerNigel Tao <nigeltao@golang.org>
Thu, 9 Aug 2012 23:34:10 +0000 (09:34 +1000)
In HTML content, having a self-closing tag is a parse error unless
the tag would be self-closing anyway (like <img>). The only place a
self-closing tag actually makes a difference is in XML-based foreign
content.

Pass 1 additional test.

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

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

index 0ae660c83dee47adaf54aac0458e8bb5eda7d3d1..1c40cd30a1df9761a0a5e81b838ed3d095eb0f35 100644 (file)
@@ -999,6 +999,10 @@ func inBodyIM(p *parser) bool {
                        adjustForeignAttributes(p.tok.Attr)
                        p.addElement()
                        p.top().Namespace = p.tok.Data
+                       if p.hasSelfClosingToken {
+                               p.oe.pop()
+                               p.acknowledgeSelfClosingTag()
+                       }
                        return true
                case a.Caption, a.Col, a.Colgroup, a.Frame, a.Head, a.Tbody, a.Td, a.Tfoot, a.Th, a.Thead, a.Tr:
                        // Ignore the token.
@@ -2011,8 +2015,8 @@ func (p *parser) parseCurrentToken() {
        }
 
        if p.hasSelfClosingToken {
+               // This is a parse error, but ignore it.
                p.hasSelfClosingToken = false
-               p.parseImpliedToken(EndTagToken, p.tok.DataAtom, p.tok.Data)
        }
 }
 
index 635cc8e180b476d24b51eea8401b6e2dd021d78f..9fd91dfb99734f94f8e2212d68c264035f9b9f73 100644 (file)
@@ -40,7 +40,7 @@ PASS "<svg><title><div>"
 PASS "<svg><title><rect><div>"
 PASS "<svg><title><svg><div>"
 PASS "<img <=\"\" FAIL>"
-FAIL "<ul><li><div id='foo'/>A</li><li>B<div>C</div></li></ul>"
+PASS "<ul><li><div id='foo'/>A</li><li>B<div>C</div></li></ul>"
 PASS "<svg><em><desc></em>"
 PASS "<table><tr><td><svg><desc><td></desc><circle>"
 PASS "<svg><tfoot></mi><td>"