1
0
mirror of https://github.com/golang/go synced 2024-11-12 03:40:21 -07:00

html: don't ignore whitespace in or after framesets

Pass tests6.dat, test 7:
<frameset></frameset>
foo

| <html>
|   <head>
|   <frameset>
|   "
"

Also pass tests through test 12:
<form><form>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5480061
This commit is contained in:
Andrew Balholm 2011-12-12 13:18:01 +11:00 committed by Nigel Tao
parent 49d82b4ca1
commit 0c5443a0a6
2 changed files with 25 additions and 1 deletions

View File

@ -1432,6 +1432,18 @@ func inFramesetIM(p *parser) bool {
Type: CommentNode,
Data: p.tok.Data,
})
case TextToken:
// Ignore all text but whitespace.
s := strings.Map(func(c rune) rune {
switch c {
case ' ', '\t', '\n', '\f', '\r':
return c
}
return -1
}, p.tok.Data)
if s != "" {
p.addText(s)
}
case StartTagToken:
switch p.tok.Data {
case "html":
@ -1470,6 +1482,18 @@ func afterFramesetIM(p *parser) bool {
Type: CommentNode,
Data: p.tok.Data,
})
case TextToken:
// Ignore all text but whitespace.
s := strings.Map(func(c rune) rune {
switch c {
case ' ', '\t', '\n', '\f', '\r':
return c
}
return -1
}, p.tok.Data)
if s != "" {
p.addText(s)
}
case StartTagToken:
switch p.tok.Data {
case "html":

View File

@ -167,7 +167,7 @@ func TestParser(t *testing.T) {
{"tests3.dat", -1},
{"tests4.dat", -1},
{"tests5.dat", -1},
{"tests6.dat", 7},
{"tests6.dat", 13},
}
for _, tf := range testFiles {
f, err := os.Open("testdata/webkit/" + tf.filename)