Commit 74db9d29 authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

exp/html: don't treat SVG <title> like HTML <title>

The content of an HTML <title> element is RCDATA, but the content of an SVG
<title> element is parsed as tags. Now the parser doesn't go into RCDATA
mode in foreign content.

Pass 4 additional tests.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6448111
parent 2f2df2ac
......@@ -1902,6 +1902,11 @@ func parseForeignContent(p *parser) bool {
namespace := p.top().Namespace
p.addElement()
p.top().Namespace = namespace
if namespace != "" {
// Don't let the tokenizer go into raw text mode in foreign content
// (e.g. in an SVG <title> tag).
p.tokenizer.rawTag = ""
}
if p.hasSelfClosingToken {
p.oe.pop()
p.acknowledgeSelfClosingTag()
......
......@@ -209,7 +209,7 @@ func render1(w writer, n *Node) error {
}
case "textarea", "title":
for _, c := range n.Child {
if c.Type != TextNode {
if c.Type != TextNode && n.Namespace == "" {
return fmt.Errorf("html: RCDATA element <%s> has non-text child node", n.Data)
}
if err := render1(w, c); err != nil {
......
......@@ -33,7 +33,7 @@ PASS "<div><svg><path><foreignObject><p></div>a"
PASS "<!DOCTYPE html><svg><desc><div><svg><ul>a"
PASS "<!DOCTYPE html><svg><desc><svg><ul>a"
PASS "<!DOCTYPE html><p><svg><desc><p>"
FAIL "<!DOCTYPE html><p><svg><title><p>"
PASS "<!DOCTYPE html><p><svg><title><p>"
PASS "<div><svg><path><foreignObject><p></foreignObject><p>"
PASS "<math><mi><div><object><div><span></span></div></object></div></mi><mi>"
PASS "<math><mi><svg><foreignObject><div><div></div></div></foreignObject></svg></mi><mi>"
......
......@@ -36,9 +36,9 @@ PASS "<kbd><table></kbd><col><select><tr></table><div>"
PASS "<a><li><style></style><title></title></a>"
PASS "<font></p><p><meta><title></title></font>"
PASS "<a><center><title></title><a>"
FAIL "<svg><title><div>"
FAIL "<svg><title><rect><div>"
FAIL "<svg><title><svg><div>"
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 "<svg><em><desc></em>"
......
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