1
0
mirror of https://github.com/golang/go synced 2024-11-21 19:14:44 -07:00

xml: Allow entities inside CDATA tags

Fixes #1112.

R=rsc
CC=golang-dev
https://golang.org/cl/2255042
This commit is contained in:
Dan Sinclair 2010-09-24 12:23:01 -04:00 committed by Russ Cox
parent 2ee420fa5e
commit 8d87ccad0b
2 changed files with 12 additions and 1 deletions

View File

@ -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.

View File

@ -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)
}
}