From: Andrew Balholm Date: Fri, 20 Apr 2012 04:25:42 +0000 (+1000) Subject: exp/html: ignore null bytes in text X-Git-Tag: go1.1rc2~3356 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6791057296ce6ff545f7a435aaebb371cb4191b9;p=gostls13.git exp/html: ignore null bytes in text pass one additional test R=golang-dev, nigeltao CC=golang-dev https://golang.org/cl/6048051 --- diff --git a/src/pkg/exp/html/parse.go b/src/pkg/exp/html/parse.go index 8f62348969..b5ee425747 100644 --- a/src/pkg/exp/html/parse.go +++ b/src/pkg/exp/html/parse.go @@ -616,25 +616,25 @@ func copyAttributes(dst *Node, src Token) { func inBodyIM(p *parser) bool { switch p.tok.Type { case TextToken: + d := p.tok.Data switch n := p.oe.top(); n.Data { case "pre", "listing", "textarea": if len(n.Child) == 0 { // Ignore a newline at the start of a
 block.
-				d := p.tok.Data
 				if d != "" && d[0] == '\r' {
 					d = d[1:]
 				}
 				if d != "" && d[0] == '\n' {
 					d = d[1:]
 				}
-				if d == "" {
-					return true
-				}
-				p.tok.Data = d
 			}
 		}
+		d = strings.Replace(d, "\x00", "", -1)
+		if d == "" {
+			return true
+		}
 		p.reconstructActiveFormattingElements()
-		p.addText(p.tok.Data)
+		p.addText(d)
 		p.framesetOK = false
 	case StartTagToken:
 		switch p.tok.Data {
diff --git a/src/pkg/exp/html/testlogs/pending-spec-changes-plain-text-unsafe.dat.log b/src/pkg/exp/html/testlogs/pending-spec-changes-plain-text-unsafe.dat.log
index 7984f34e17..bbcad900aa 100644
--- a/src/pkg/exp/html/testlogs/pending-spec-changes-plain-text-unsafe.dat.log
+++ b/src/pkg/exp/html/testlogs/pending-spec-changes-plain-text-unsafe.dat.log
@@ -1 +1 @@
-FAIL "\x00filler\x00text\x00"
+PASS "
\x00filler\x00text\x00"