diff options
author | Michal Bohuslávek <mbohuslavek@gmail.com> | 2015-09-02 19:05:22 +0200 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2015-11-25 17:08:38 +0000 |
commit | 97c859f8da0c85c33d0f29ba5e11094d8e691e87 (patch) | |
tree | 20794c155502b2242a2e3e132d18017d4aa87217 /src/encoding/xml/read_test.go | |
parent | 3f6b91b1136e25e75da71b727e536ba4f4066fd5 (diff) | |
download | go-97c859f8da0c85c33d0f29ba5e11094d8e691e87.tar.gz go-97c859f8da0c85c33d0f29ba5e11094d8e691e87.zip |
encoding/xml: reject invalid comments
Fixes #11112.
Change-Id: I16e7363549a0dec8c61addfa14af0866c1fd7c40
Reviewed-on: https://go-review.googlesource.com/14173
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/encoding/xml/read_test.go')
-rw-r--r-- | src/encoding/xml/read_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/encoding/xml/read_test.go b/src/encoding/xml/read_test.go index 7d004dc488..7a98092803 100644 --- a/src/encoding/xml/read_test.go +++ b/src/encoding/xml/read_test.go @@ -712,3 +712,24 @@ func TestUnmarshalIntoInterface(t *testing.T) { t.Errorf("failed to unmarshal into interface, have %q want %q", have, want) } } + +type X struct { + D string `xml:",comment"` +} + +// Issue 11112. Unmarshal must reject invalid comments. +func TestMalformedComment(t *testing.T) { + testData := []string{ + "<X><!-- a---></X>", + "<X><!-- -- --></X>", + "<X><!-- a--b --></X>", + "<X><!------></X>", + } + for i, test := range testData { + data := []byte(test) + v := new(X) + if err := Unmarshal(data, v); err == nil { + t.Errorf("%d: unmarshal should reject invalid comments", i) + } + } +} |