mirror of
https://github.com/golang/go
synced 2024-11-25 03:47:57 -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:
parent
49d82b4ca1
commit
0c5443a0a6
@ -1432,6 +1432,18 @@ func inFramesetIM(p *parser) bool {
|
|||||||
Type: CommentNode,
|
Type: CommentNode,
|
||||||
Data: p.tok.Data,
|
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:
|
case StartTagToken:
|
||||||
switch p.tok.Data {
|
switch p.tok.Data {
|
||||||
case "html":
|
case "html":
|
||||||
@ -1470,6 +1482,18 @@ func afterFramesetIM(p *parser) bool {
|
|||||||
Type: CommentNode,
|
Type: CommentNode,
|
||||||
Data: p.tok.Data,
|
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:
|
case StartTagToken:
|
||||||
switch p.tok.Data {
|
switch p.tok.Data {
|
||||||
case "html":
|
case "html":
|
||||||
|
@ -167,7 +167,7 @@ func TestParser(t *testing.T) {
|
|||||||
{"tests3.dat", -1},
|
{"tests3.dat", -1},
|
||||||
{"tests4.dat", -1},
|
{"tests4.dat", -1},
|
||||||
{"tests5.dat", -1},
|
{"tests5.dat", -1},
|
||||||
{"tests6.dat", 7},
|
{"tests6.dat", 13},
|
||||||
}
|
}
|
||||||
for _, tf := range testFiles {
|
for _, tf := range testFiles {
|
||||||
f, err := os.Open("testdata/webkit/" + tf.filename)
|
f, err := os.Open("testdata/webkit/" + tf.filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user