Commit 8d87ccad authored by Dan Sinclair's avatar Dan Sinclair Committed by Russ Cox

xml: Allow entities inside CDATA tags

Fixes #1112.

R=rsc
CC=golang-dev
https://golang.org/cl/2255042
parent 2ee420fa
......@@ -790,7 +790,7 @@ Input:
if quote >= 0 && b == byte(quote) {
break Input
}
if b == '&' {
if b == '&' && !cdata {
// Read escaped character expression up to semicolon.
// XML in all its glory allows a document to define and use
// its own character names with <!ENTITY ...> directives.
......
......@@ -387,3 +387,14 @@ func TestTrailingToken(t *testing.T) {
t.Fatalf("p.Token() = _, %v, want _, os.EOF", err)
}
}
func TestEntityInsideCDATA(t *testing.T) {
input := `<test><![CDATA[ &val=foo ]]></test>`
p := NewParser(StringReader(input))
var err os.Error
for _, err = p.Token(); err == nil; _, err = p.Token() {
}
if err != os.EOF {
t.Fatalf("p.Token() = _, %v, want _, os.EOF", err)
}
}
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