]> Cypherpunks repositories - gostls13.git/commitdiff
html: parse <style> elements inside <head> element.
authorAndrew Balholm <andybalholm@gmail.com>
Wed, 26 Oct 2011 23:26:11 +0000 (10:26 +1100)
committerNigel Tao <nigeltao@golang.org>
Wed, 26 Oct 2011 23:26:11 +0000 (10:26 +1100)
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

src/pkg/html/parse.go
src/pkg/html/parse_test.go

index 823f7aad29f5afab4c8aacb5080fcffd6f479ce6..276f0b7fbfa07c9aa15f5fe61b2ef95d0b12f5a3 100644 (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
index 5022a4f7798f06b034b0e194a8dda6ff72c3048a..86f1298d5ee557e933e93ad0c95b32278385cae5 100644 (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 {