From a0bd46e70fa09e8fe4749399440a2dc52e80f84a Mon Sep 17 00:00:00 2001 From: Andrew Balholm Date: Tue, 20 Dec 2011 10:57:06 +1100 Subject: [PATCH] html: ignore , , etc. when parsing table fragments Pass tests6.dat, test 36: | Pass tests through test 44: R=nigeltao CC=golang-dev https://golang.org/cl/5494055 --- src/pkg/html/parse.go | 7 +++++++ src/pkg/html/parse_test.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go index a69262115c..6892d8fefa 100644 --- a/src/pkg/html/parse.go +++ b/src/pkg/html/parse.go @@ -1206,6 +1206,13 @@ func inTableBodyIM(p *parser) bool { add = true data = "tr" consumed = false + case "caption", "col", "colgroup", "tbody", "tfoot", "thead": + if !p.popUntil(tableScopeStopTags, "tbody", "thead", "tfoot") { + // Ignore the token. + return true + } + p.im = inTableIM + return false default: // TODO. } diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go index b938ca7185..7ca2922cc3 100644 --- a/src/pkg/html/parse_test.go +++ b/src/pkg/html/parse_test.go @@ -172,7 +172,7 @@ func TestParser(t *testing.T) { {"tests3.dat", -1}, {"tests4.dat", -1}, {"tests5.dat", -1}, - {"tests6.dat", 36}, + {"tests6.dat", 45}, {"tests10.dat", 13}, } for _, tf := range testFiles {