]> Cypherpunks repositories - gostls13.git/commitdiff
html: don't run "adoption agency" on elements that aren't in scope.
authorAndrew Balholm <andybalholm@gmail.com>
Fri, 28 Oct 2011 05:04:58 +0000 (16:04 +1100)
committerNigel Tao <nigeltao@golang.org>
Fri, 28 Oct 2011 05:04:58 +0000 (16:04 +1100)
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

src/pkg/html/parse.go
src/pkg/html/parse_test.go

index fdd6f75aabd7523091bbc808aa8407265e1320a7..b0348790c19f4d9c9f1482ef78dc8addf5c1aa98 100644 (file)
@@ -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
index ae4ecd6658a0f4d4f2b8e998e67da174648775bd..e86a36f18a8b0e91f8b498208c1c5c19496e4647 100644 (file)
@@ -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 {