mirror of https://github.com/golang/go.git
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
This commit is contained in:
parent
2f2df2aceb
commit
74db9d298b
|
|
@ -1902,6 +1902,11 @@ func parseForeignContent(p *parser) bool {
|
||||||
namespace := p.top().Namespace
|
namespace := p.top().Namespace
|
||||||
p.addElement()
|
p.addElement()
|
||||||
p.top().Namespace = namespace
|
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 {
|
if p.hasSelfClosingToken {
|
||||||
p.oe.pop()
|
p.oe.pop()
|
||||||
p.acknowledgeSelfClosingTag()
|
p.acknowledgeSelfClosingTag()
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ func render1(w writer, n *Node) error {
|
||||||
}
|
}
|
||||||
case "textarea", "title":
|
case "textarea", "title":
|
||||||
for _, c := range n.Child {
|
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)
|
return fmt.Errorf("html: RCDATA element <%s> has non-text child node", n.Data)
|
||||||
}
|
}
|
||||||
if err := render1(w, c); err != nil {
|
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><div><svg><ul>a"
|
||||||
PASS "<!DOCTYPE html><svg><desc><svg><ul>a"
|
PASS "<!DOCTYPE html><svg><desc><svg><ul>a"
|
||||||
PASS "<!DOCTYPE html><p><svg><desc><p>"
|
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 "<div><svg><path><foreignObject><p></foreignObject><p>"
|
||||||
PASS "<math><mi><div><object><div><span></span></div></object></div></mi><mi>"
|
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>"
|
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 "<a><li><style></style><title></title></a>"
|
||||||
PASS "<font></p><p><meta><title></title></font>"
|
PASS "<font></p><p><meta><title></title></font>"
|
||||||
PASS "<a><center><title></title><a>"
|
PASS "<a><center><title></title><a>"
|
||||||
FAIL "<svg><title><div>"
|
PASS "<svg><title><div>"
|
||||||
FAIL "<svg><title><rect><div>"
|
PASS "<svg><title><rect><div>"
|
||||||
FAIL "<svg><title><svg><div>"
|
PASS "<svg><title><svg><div>"
|
||||||
PASS "<img <=\"\" FAIL>"
|
PASS "<img <=\"\" FAIL>"
|
||||||
FAIL "<ul><li><div id='foo'/>A</li><li>B<div>C</div></li></ul>"
|
FAIL "<ul><li><div id='foo'/>A</li><li>B<div>C</div></li></ul>"
|
||||||
PASS "<svg><em><desc></em>"
|
PASS "<svg><em><desc></em>"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue