1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:54:39 -07:00

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
This commit is contained in:
Andrew Balholm 2012-07-29 16:29:49 +10:00 committed by Nigel Tao
parent f7f91a0506
commit eff32f573b
2 changed files with 9 additions and 7 deletions

View File

@ -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{

View File

@ -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>"