html: ignore <caption>, <col>, <tbody> etc. when parsing table fragments

Pass tests6.dat, test 36:
<caption><col><colgroup><tbody><tfoot><thead><tr>

| <tr>

Pass tests through test 44:
<body></body></html>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5494055
This commit is contained in:
Andrew Balholm 2011-12-20 10:57:06 +11:00 committed by Nigel Tao
parent 315b361f89
commit a0bd46e70f
2 changed files with 8 additions and 1 deletions

View File

@ -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.
}

View File

@ -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 {