]> Cypherpunks repositories - gostls13.git/commitdiff
exp/html: ignore null bytes in text
authorAndrew Balholm <andybalholm@gmail.com>
Fri, 20 Apr 2012 04:25:42 +0000 (14:25 +1000)
committerNigel Tao <nigeltao@golang.org>
Fri, 20 Apr 2012 04:25:42 +0000 (14:25 +1000)
pass one additional test

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6048051

src/pkg/exp/html/parse.go
src/pkg/exp/html/testlogs/pending-spec-changes-plain-text-unsafe.dat.log

index 8f62348969ff5a4b95414ab08c1807ba97335c69..b5ee425747bb4793aad0004b26fd5b8d7203e8e9 100644 (file)
@@ -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 <pre> 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 {
index 7984f34e1707618d3702c773e5c36c487950ec05..bbcad900aa23fbbcc9785e937522205872cee0b3 100644 (file)
@@ -1 +1 @@
-FAIL "<body><table>\x00filler\x00text\x00"
+PASS "<body><table>\x00filler\x00text\x00"