Commit 833fb419 authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

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
parent bd07e4f2
...@@ -443,7 +443,7 @@ func inHeadIM(p *parser) (insertionMode, bool) { ...@@ -443,7 +443,7 @@ func inHeadIM(p *parser) (insertionMode, bool) {
switch p.tok.Data { switch p.tok.Data {
case "meta": case "meta":
// TODO. // TODO.
case "script", "title": case "script", "title", "noscript", "noframes", "style":
p.addElement(p.tok.Data, p.tok.Attr) p.addElement(p.tok.Data, p.tok.Attr)
p.setOriginalIM(inHeadIM) p.setOriginalIM(inHeadIM)
return textIM, true return textIM, true
...@@ -763,6 +763,8 @@ func (p *parser) inBodyEndTagOther(tag string) { ...@@ -763,6 +763,8 @@ func (p *parser) inBodyEndTagOther(tag string) {
// Section 11.2.5.4.8. // Section 11.2.5.4.8.
func textIM(p *parser) (insertionMode, bool) { func textIM(p *parser) (insertionMode, bool) {
switch p.tok.Type { switch p.tok.Type {
case ErrorToken:
p.oe.pop()
case TextToken: case TextToken:
p.addText(p.tok.Data) p.addText(p.tok.Data)
return textIM, true return textIM, true
......
...@@ -132,7 +132,7 @@ func TestParser(t *testing.T) { ...@@ -132,7 +132,7 @@ func TestParser(t *testing.T) {
rc := make(chan io.Reader) rc := make(chan io.Reader)
go readDat(filename, rc) go readDat(filename, rc)
// TODO(nigeltao): Process all test cases, not just a subset. // 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. // Parse the #data section.
b, err := ioutil.ReadAll(<-rc) b, err := ioutil.ReadAll(<-rc)
if err != nil { if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment