mirror of
https://github.com/golang/go
synced 2024-11-25 09:57:57 -07:00
html: allow whitespace between head and body
Also ignore <head> tag after </head>. Pass tests6.dat, test 0: <!doctype html></head> <head> | <!DOCTYPE html> | <html> | <head> | " " | <body> Also pass tests through test 6: <body> <div> R=nigeltao CC=golang-dev https://golang.org/cl/5447064
This commit is contained in:
parent
6ea3a268b6
commit
a5d300862b
@ -515,7 +515,19 @@ func afterHeadIM(p *parser) bool {
|
|||||||
implied bool
|
implied bool
|
||||||
)
|
)
|
||||||
switch p.tok.Type {
|
switch p.tok.Type {
|
||||||
case ErrorToken, TextToken:
|
case ErrorToken:
|
||||||
|
implied = true
|
||||||
|
framesetOK = true
|
||||||
|
case TextToken:
|
||||||
|
s := strings.TrimLeft(p.tok.Data, whitespace)
|
||||||
|
if len(s) < len(p.tok.Data) {
|
||||||
|
// Add the initial whitespace to the current node.
|
||||||
|
p.addText(p.tok.Data[:len(p.tok.Data)-len(s)])
|
||||||
|
if s == "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
p.tok.Data = s
|
||||||
|
}
|
||||||
implied = true
|
implied = true
|
||||||
framesetOK = true
|
framesetOK = true
|
||||||
case StartTagToken:
|
case StartTagToken:
|
||||||
@ -535,7 +547,8 @@ func afterHeadIM(p *parser) bool {
|
|||||||
defer p.oe.pop()
|
defer p.oe.pop()
|
||||||
return inHeadIM(p)
|
return inHeadIM(p)
|
||||||
case "head":
|
case "head":
|
||||||
// TODO.
|
// Ignore the token.
|
||||||
|
return true
|
||||||
default:
|
default:
|
||||||
implied = true
|
implied = true
|
||||||
framesetOK = true
|
framesetOK = true
|
||||||
|
@ -167,6 +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},
|
||||||
}
|
}
|
||||||
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