Commit eff32f57 authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

exp/html: replace NUL with U+FFFD in text in foreign content

Pass 5 additional tests.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6452055
parent f7f91a05
......@@ -1846,14 +1846,16 @@ func afterAfterFramesetIM(p *parser) bool {
return true
}
const whitespaceOrNUL = whitespace + "\x00"
// Section 12.2.5.5.
func parseForeignContent(p *parser) bool {
switch p.tok.Type {
case TextToken:
p.tok.Data = strings.Replace(p.tok.Data, "\x00", "", -1)
if p.framesetOK {
p.framesetOK = strings.TrimLeft(p.tok.Data, whitespace) == ""
p.framesetOK = strings.TrimLeft(p.tok.Data, whitespaceOrNUL) == ""
}
p.tok.Data = strings.Replace(p.tok.Data, "\x00", "\ufffd", -1)
p.addText(p.tok.Data)
case CommentToken:
p.addChild(&Node{
......
......@@ -12,13 +12,13 @@ PASS "<svg><![CDATA[\x00filler\x00text\x00]]>"
PASS "<body><!\x00>"
PASS "<body><!\x00filler\x00text>"
PASS "<body><svg><foreignObject>\x00filler\x00text"
FAIL "<svg>\x00filler\x00text"
FAIL "<svg>\x00<frameset>"
FAIL "<svg>\x00 <frameset>"
FAIL "<svg>\x00a<frameset>"
PASS "<svg>\x00filler\x00text"
PASS "<svg>\x00<frameset>"
PASS "<svg>\x00 <frameset>"
PASS "<svg>\x00a<frameset>"
PASS "<svg>\x00</svg><frameset>"
PASS "<svg>\x00 </svg><frameset>"
FAIL "<svg>\x00a</svg><frameset>"
PASS "<svg>\x00a</svg><frameset>"
PASS "<svg><path></path></svg><frameset>"
PASS "<svg><p><frameset>"
PASS "<!DOCTYPE html><pre>\r\n\r\nA</pre>"
......
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