]> Cypherpunks repositories - gostls13.git/commitdiff
xml: Fixed CDATA parsing.
authorAbhinav Gupta <abhinav.g90@gmail.com>
Sat, 14 Nov 2009 19:46:09 +0000 (11:46 -0800)
committerRuss Cox <rsc@golang.org>
Sat, 14 Nov 2009 19:46:09 +0000 (11:46 -0800)
    Fixes #128.

R=r, rsc
https://golang.org/cl/154126

src/pkg/xml/xml.go
src/pkg/xml/xml_test.go

index b8809422d835e702000c56333dfd5af7fc287231..202cd4626221c3d9011e157e1845945b07232f4d 100644 (file)
@@ -497,11 +497,11 @@ func (p *Parser) RawToken() (Token, os.Error) {
 
                case '[':       // <![
                        // Probably <![CDATA[.
-                       for i := 0; i < 7; i++ {
+                       for i := 0; i < 6; i++ {
                                if b, ok = p.getc(); !ok {
                                        return nil, p.err
                                }
-                               if b != "[CDATA["[i] {
+                               if b != "CDATA["[i] {
                                        p.err = SyntaxError("invalid <![ sequence");
                                        return nil, p.err;
                                }
index 058c1e7658e7169c4fcfc1786b46075ded48d65a..11918428b2092bbe279ba6a89dbdcbf59e8acf77 100644 (file)
@@ -24,7 +24,7 @@ const testInput = `
     <inner/>
   </outer>
   <tag:name>
-    Some text here.
+    <![CDATA[Some text here.]]>
   </tag:name>
 </body><!-- missing final newline -->`
 
@@ -52,7 +52,9 @@ var rawTokens = []Token{
        EndElement{Name{"", "outer"}},
        CharData(strings.Bytes("\n  ")),
        StartElement{Name{"tag", "name"}, nil},
-       CharData(strings.Bytes("\n    Some text here.\n  ")),
+       CharData(strings.Bytes("\n    ")),
+       CharData(strings.Bytes("Some text here.")),
+       CharData(strings.Bytes("\n  ")),
        EndElement{Name{"tag", "name"}},
        CharData(strings.Bytes("\n")),
        EndElement{Name{"", "body"}},
@@ -83,7 +85,9 @@ var cookedTokens = []Token{
        EndElement{Name{"ns2", "outer"}},
        CharData(strings.Bytes("\n  ")),
        StartElement{Name{"ns3", "name"}, nil},
-       CharData(strings.Bytes("\n    Some text here.\n  ")),
+       CharData(strings.Bytes("\n    ")),
+       CharData(strings.Bytes("Some text here.")),
+       CharData(strings.Bytes("\n  ")),
        EndElement{Name{"ns3", "name"}},
        CharData(strings.Bytes("\n")),
        EndElement{Name{"ns2", "body"}},