From 03f163c7f22bfaab69a56d48160b0a184ce6bf54 Mon Sep 17 00:00:00 2001 From: Andrew Balholm Date: Fri, 28 Oct 2011 16:04:58 +1100 Subject: [PATCH] html: don't run "adoption agency" on elements that aren't in scope. Pass tests1.dat, test 55:
| | | | | | Also pass tests through test 69:
abc def ghi

jkl R=nigeltao CC=golang-dev https://golang.org/cl/5309074 --- src/pkg/html/parse.go | 4 ++++ src/pkg/html/parse_test.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go index fdd6f75aabd..b0348790c19 100644 --- a/src/pkg/html/parse.go +++ b/src/pkg/html/parse.go @@ -675,6 +675,10 @@ func (p *parser) inBodyEndTagFormatting(tag string) { p.afe.remove(formattingElement) return } + if !p.elementInScope(defaultScopeStopTags, tag) { + // Ignore the tag. + return + } // Steps 5-6. Find the furthest block. var furthestBlock *Node diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go index ae4ecd6658a..e86a36f18a8 100644 --- a/src/pkg/html/parse_test.go +++ b/src/pkg/html/parse_test.go @@ -132,7 +132,7 @@ func TestParser(t *testing.T) { rc := make(chan io.Reader) go readDat(filename, rc) // TODO(nigeltao): Process all test cases, not just a subset. - for i := 0; i < 55; i++ { + for i := 0; i < 70; i++ { // Parse the #data section. b, err := ioutil.ReadAll(<-rc) if err != nil {