1
0
mirror of https://github.com/golang/go synced 2024-11-21 14:34:41 -07:00

html: parse <style> elements inside <head> element.

Also correctly handle EOF inside a <style> element.

Pass tests1.dat, test 49:
<!DOCTYPE html><style> EOF

| <!DOCTYPE html>
| <html>
|   <head>
|     <style>
|       " EOF"
|   <body>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5321057
This commit is contained in:
Andrew Balholm 2011-10-27 10:26:11 +11:00 committed by Nigel Tao
parent bd07e4f259
commit 833fb4198d
2 changed files with 4 additions and 2 deletions

View File

@ -443,7 +443,7 @@ func inHeadIM(p *parser) (insertionMode, bool) {
switch p.tok.Data {
case "meta":
// TODO.
case "script", "title":
case "script", "title", "noscript", "noframes", "style":
p.addElement(p.tok.Data, p.tok.Attr)
p.setOriginalIM(inHeadIM)
return textIM, true
@ -763,6 +763,8 @@ func (p *parser) inBodyEndTagOther(tag string) {
// Section 11.2.5.4.8.
func textIM(p *parser) (insertionMode, bool) {
switch p.tok.Type {
case ErrorToken:
p.oe.pop()
case TextToken:
p.addText(p.tok.Data)
return textIM, true

View 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 < 49; i++ {
for i := 0; i < 50; i++ {
// Parse the #data section.
b, err := ioutil.ReadAll(<-rc)
if err != nil {