]> Cypherpunks repositories - gostls13.git/commitdiff
exp/html: don't insert empty text nodes
authorAndrew Balholm <andybalholm@gmail.com>
Thu, 26 Jul 2012 00:32:24 +0000 (10:32 +1000)
committerNigel Tao <nigeltao@golang.org>
Thu, 26 Jul 2012 00:32:24 +0000 (10:32 +1000)
Pass 1 additional test.

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

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

index 393a97d2eedbd161ccf246f1543d6273e0c2616c..82edb2263f8cda0f19b3f7529a341ef5a6cda1f5 100644 (file)
@@ -267,6 +267,9 @@ func (p *parser) fosterParent(n *Node) {
 // addText adds text to the preceding node if it is a text node, or else it
 // calls addChild with a new text node.
 func (p *parser) addText(text string) {
+       if text == "" {
+               return
+       }
        // TODO: distinguish whitespace text from others.
        t := p.top()
        if i := len(t.Child); i > 0 && t.Child[i-1].Type == TextNode {
index 80f6f92d06979ab17aebaa10a55a6c3744c73ba5..56da0ba88f20dbf10b2a38c7960b3c3d7bf5cae7 100644 (file)
@@ -4,7 +4,7 @@ PASS "<html> \x00 <frameset></frameset>"
 PASS "<html>a\x00a<frameset></frameset>"
 PASS "<html>\x00\x00<frameset></frameset>"
 PASS "<html>\x00\n <frameset></frameset>"
-FAIL "<html><select>\x00"
+PASS "<html><select>\x00"
 PASS "\x00"
 PASS "<body>\x00"
 FAIL "<plaintext>\x00filler\x00text\x00"