From: Andrew Balholm Date: Thu, 26 Jul 2012 00:32:24 +0000 (+1000) Subject: exp/html: don't insert empty text nodes X-Git-Tag: go1.1rc2~2776 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=899be50991b71b0eb32fcbff5a7eb151dcb995f6;p=gostls13.git exp/html: don't insert empty text nodes Pass 1 additional test. R=nigeltao CC=golang-dev https://golang.org/cl/6443048 --- diff --git a/src/pkg/exp/html/parse.go b/src/pkg/exp/html/parse.go index 393a97d2ee..82edb2263f 100644 --- a/src/pkg/exp/html/parse.go +++ b/src/pkg/exp/html/parse.go @@ -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 { diff --git a/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log b/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log index 80f6f92d06..56da0ba88f 100644 --- a/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log +++ b/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log @@ -4,7 +4,7 @@ PASS " \x00 " PASS "a\x00a" PASS "\x00\x00" PASS "\x00\n " -FAIL "\x00" PASS "\x00" PASS "\x00" FAIL "\x00filler\x00text\x00"