summaryrefslogtreecommitdiff
path: root/libgo/go/encoding/xml/read_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/encoding/xml/read_test.go')
-rw-r--r--libgo/go/encoding/xml/read_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/libgo/go/encoding/xml/read_test.go b/libgo/go/encoding/xml/read_test.go
index 7d004dc488c..7a98092803a 100644
--- a/libgo/go/encoding/xml/read_test.go
+++ b/libgo/go/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)
+ }
+ }
+}