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

exp/html: ignore null bytes in text

pass one additional test

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6048051
This commit is contained in:
Andrew Balholm 2012-04-20 14:25:42 +10:00 committed by Nigel Tao
parent 7d63ff09a5
commit 6791057296
2 changed files with 7 additions and 7 deletions

View File

@ -616,25 +616,25 @@ func copyAttributes(dst *Node, src Token) {
func inBodyIM(p *parser) bool { func inBodyIM(p *parser) bool {
switch p.tok.Type { switch p.tok.Type {
case TextToken: case TextToken:
d := p.tok.Data
switch n := p.oe.top(); n.Data { switch n := p.oe.top(); n.Data {
case "pre", "listing", "textarea": case "pre", "listing", "textarea":
if len(n.Child) == 0 { if len(n.Child) == 0 {
// Ignore a newline at the start of a <pre> block. // Ignore a newline at the start of a <pre> block.
d := p.tok.Data
if d != "" && d[0] == '\r' { if d != "" && d[0] == '\r' {
d = d[1:] d = d[1:]
} }
if d != "" && d[0] == '\n' { if d != "" && d[0] == '\n' {
d = d[1:] d = d[1:]
} }
if d == "" {
return true
}
p.tok.Data = d
} }
} }
d = strings.Replace(d, "\x00", "", -1)
if d == "" {
return true
}
p.reconstructActiveFormattingElements() p.reconstructActiveFormattingElements()
p.addText(p.tok.Data) p.addText(d)
p.framesetOK = false p.framesetOK = false
case StartTagToken: case StartTagToken:
switch p.tok.Data { switch p.tok.Data {

View File

@ -1 +1 @@
FAIL "<body><table>\x00filler\x00text\x00" PASS "<body><table>\x00filler\x00text\x00"