Skip to content

Commit 5bc1aba

Browse files
committed
XML: fix unescaping of >, fixes #825
1 parent fb9d8da commit 5bc1aba

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

‎xml/table.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package xml
33
// EntitiesMap are all named character entities.
44
var EntitiesMap = map[string][]byte{
55
"apos": []byte("'"),
6-
"gt": []byte(">"),
76
"quot": []byte("\""),
87
}
98

109
// TextRevEntitiesMap is a map of escapes.
1110
var TextRevEntitiesMap = map[byte][]byte{
1211
'<': []byte("&lt;"),
12+
'>': []byte("&gt;"),
1313
'&': []byte("&amp;"),
1414
}

‎xml/xml_test.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func TestXML(t *testing.T) {
3232
{"<x a=\" a \n\r\t b \"/>", `<x a=" a b "/>`},
3333
{`<x a="&apos;b&quot;"></x>`, `<x a="'b&#34;"/>`},
3434
{`<x a="&quot;&quot;'"></x>`, `<x a='""&#39;'/>`},
35-
{`<x a="&amp;&lt;&gt;"></x>`, `<x a="&amp;&lt;>"/>`},
36-
{`<x>&amp;&lt;&gt;</x>`, `<x>&amp;&lt;></x>`},
35+
{`<x a="&amp;&lt;&gt;"></x>`, `<x a="&amp;&lt;&gt;"/>`},
36+
{`<x>&amp;&lt;&gt;</x>`, `<x>&amp;&lt;&gt;</x>`},
3737
{`<x>&#38;&#038;&#60;</x>`, `<x>&amp;&amp;&lt;</x>`},
3838
{`<!DOCTYPE foo SYSTEM "Foo.dtd">`, `<!DOCTYPE foo SYSTEM "Foo.dtd">`},
3939
{`text <!--comment--> text`, `text text`},
@@ -42,6 +42,7 @@ func TestXML(t *testing.T) {
4242
{"<x>\n<!--y-->\n</x>", `<x></x>`},
4343
{`<style>lala{color:red}</style>`, `<style>lala{color:red}</style>`},
4444
{`cats and dogs `, `cats and dogs`},
45+
{`<x> ]]&gt; </x>`, `<x>]]&gt;</x>`}, // #825
4546

4647
// go fuzz
4748
{`</0`, `</0`},

0 commit comments

Comments
 (0)