From 899be50991b71b0eb32fcbff5a7eb151dcb995f6 Mon Sep 17 00:00:00 2001 From: Andrew Balholm Date: Thu, 26 Jul 2012 10:32:24 +1000 Subject: [PATCH] exp/html: don't insert empty text nodes Pass 1 additional test. R=nigeltao CC=golang-dev https://golang.org/cl/6443048 --- src/pkg/exp/html/parse.go | 3 +++ src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pkg/exp/html/parse.go b/src/pkg/exp/html/parse.go index 393a97d2eed..82edb2263f8 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 80f6f92d069..56da0ba88f2 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"