diff options
author | Andrew Balholm <andybalholm@gmail.com> | 2011-10-28 16:04:58 +1100 |
---|---|---|
committer | Nigel Tao <nigeltao@golang.org> | 2011-10-28 16:04:58 +1100 |
commit | 03f163c7f22bfaab69a56d48160b0a184ce6bf54 (patch) | |
tree | ce1e8d8bba1c375db4ba0dfa4c2266d2aab622af | |
parent | 0e81e508bedec7e25aafc5b3939901dbc1d67914 (diff) | |
download | go-03f163c7f22bfaab69a56d48160b0a184ce6bf54.tar.gz go-03f163c7f22bfaab69a56d48160b0a184ce6bf54.zip |
html: don't run "adoption agency" on elements that aren't in scope.
Pass tests1.dat, test 55:
<!DOCTYPE html><font><table></font></table></font>
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| <font>
| <table>
Also pass tests through test 69:
<DIV> abc <B> def <I> ghi <P> jkl
R=nigeltao
CC=golang-dev
https://golang.org/cl/5309074
-rw-r--r-- | src/pkg/html/parse.go | 4 | ||||
-rw-r--r-- | src/pkg/html/parse_test.go | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go index fdd6f75aab..b0348790c1 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 ae4ecd6658..e86a36f18a 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 { |