From 0c5443a0a61182276f755c1c728d4990cf0983e9 Mon Sep 17 00:00:00 2001 From: Andrew Balholm Date: Mon, 12 Dec 2011 13:18:01 +1100 Subject: [PATCH] html: don't ignore whitespace in or after framesets Pass tests6.dat, test 7: foo | | | | " " Also pass tests through test 12:
R=nigeltao CC=golang-dev https://golang.org/cl/5480061 --- src/pkg/html/parse.go | 24 ++++++++++++++++++++++++ src/pkg/html/parse_test.go | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go index dd2d8165bd..24cb323a59 100644 --- a/src/pkg/html/parse.go +++ b/src/pkg/html/parse.go @@ -1432,6 +1432,18 @@ func inFramesetIM(p *parser) bool { Type: CommentNode, Data: p.tok.Data, }) + case TextToken: + // Ignore all text but whitespace. + s := strings.Map(func(c rune) rune { + switch c { + case ' ', '\t', '\n', '\f', '\r': + return c + } + return -1 + }, p.tok.Data) + if s != "" { + p.addText(s) + } case StartTagToken: switch p.tok.Data { case "html": @@ -1470,6 +1482,18 @@ func afterFramesetIM(p *parser) bool { Type: CommentNode, Data: p.tok.Data, }) + case TextToken: + // Ignore all text but whitespace. + s := strings.Map(func(c rune) rune { + switch c { + case ' ', '\t', '\n', '\f', '\r': + return c + } + return -1 + }, p.tok.Data) + if s != "" { + p.addText(s) + } case StartTagToken: switch p.tok.Data { case "html": diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go index 5062a6edcb..8f8787886c 100644 --- a/src/pkg/html/parse_test.go +++ b/src/pkg/html/parse_test.go @@ -167,7 +167,7 @@ func TestParser(t *testing.T) { {"tests3.dat", -1}, {"tests4.dat", -1}, {"tests5.dat", -1}, - {"tests6.dat", 7}, + {"tests6.dat", 13}, } for _, tf := range testFiles { f, err := os.Open("testdata/webkit/" + tf.filename) -- 2.50.0