]> Cypherpunks repositories - gostls13.git/commitdiff
html: don't emit text token for empty raw text elements.
authorAndrew Balholm <andybalholm@gmail.com>
Wed, 9 Nov 2011 21:09:54 +0000 (08:09 +1100)
committerNigel Tao <nigeltao@golang.org>
Wed, 9 Nov 2011 21:09:54 +0000 (08:09 +1100)
Pass tests1.dat, test 99:
<script></script></div><title></title><p><p>

| <html>
|   <head>
|     <script>
|     <title>
|   <body>
|     <p>
|     <p>

Also pass tests through test 105:
<ul><li><ul></li><li>a</li></ul></li></ul>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5373043

src/pkg/html/parse_test.go
src/pkg/html/token.go

index 14863da79f602c4e8215ec3694619dd5c7f5bd0f..8cef0fa8e3671d6ea7df94ebb41bf73237207a36 100644 (file)
@@ -133,7 +133,7 @@ func TestParser(t *testing.T) {
                n int
        }{
                // TODO(nigeltao): Process all the test cases from all the .dat files.
-               {"tests1.dat", 99},
+               {"tests1.dat", 106},
                {"tests2.dat", 0},
                {"tests3.dat", 0},
        }
@@ -213,4 +213,5 @@ var renderTestBlacklist = map[string]bool{
        // More cases of <a> being reparented:
        `<a href="blah">aba<table><a href="foo">br<tr><td></td></tr>x</table>aoe`: true,
        `<a><table><a></table><p><a><div><a>`:                                     true,
+       `<a><table><td><a><table></table><a></tr><a></table><a>`:                  true,
 }
index 2c138227b1049ffc738712a677a452e1bd0a19db..78a240a66f1c502619e21e1a271570c3083c6365 100644 (file)
@@ -552,8 +552,10 @@ func (z *Tokenizer) Next() TokenType {
        z.data.end = z.raw.end
        if z.rawTag != "" {
                z.readRawOrRCDATA()
-               z.tt = TextToken
-               return z.tt
+               if z.data.end > z.data.start {
+                       z.tt = TextToken
+                       return z.tt
+               }
        }
        z.textIsRaw = false