You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
Build and run the following code:
package main
import "xml"
import "strings"
import "fmt"
import "os"
func main() {
fragment := `<test><![CDATA[ &val=foo ]]></test>`
parser := xml.NewParser(strings.NewReader(fragment))
var err os.Error
for {
if _, err = parser.Token(); err != nil {
if err == os.EOF {
return
}
fmt.Fprintf(os.Stderr, "Xml Error: %s\n", err)
return
}
}
}
What is the expected output?
Program should run without error.
What do you see instead?
Xml Error: XML syntax error on line 1: invalid character entity &val;
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
64-bit ArchLinux
Which revision are you using? (hg identify)
e1752be5d932 tip
Please provide any additional information below.
The XML parser in the Go xml package should ignore special tokens like & and < or
> when they are inside a <![CDATA[ ... ]]> tag.
The current implementation does not and consequently yields parse errors where it should
not.
The text was updated successfully, but these errors were encountered:
For completeness, here is a link and excerpt of the XML specification:
http://www.w3.org/TR/REC-xml/#sec-cdata-sect
[Definition: CDATA sections may occur anywhere character data may occur; they are used
to escape blocks of text containing characters which would otherwise be recognized as
markup. CDATA sections begin with the string " <![CDATA[ " and end with the string "
]]> ":]
Within a CDATA section, only the CDEnd string ("]]>") is recognized as markup, so
that left angle brackets and ampersands may occur in their literal form; they need not
(and cannot) be escaped using " < " and " & ". CDATA sections cannot nest.
by jimteeuwen:
The text was updated successfully, but these errors were encountered: