encoding/xml: fix panic in Marshal
Fixes #6341.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13512048
diff --git a/src/pkg/encoding/xml/marshal.go b/src/pkg/encoding/xml/marshal.go
index a6ee5d5..ac6c629 100644
--- a/src/pkg/encoding/xml/marshal.go
+++ b/src/pkg/encoding/xml/marshal.go
@@ -655,7 +655,10 @@
case reflect.Bool:
return strconv.FormatBool(val.Bool()), nil, nil
case reflect.Array:
- // will be [...]byte
+ if typ.Elem().Kind() != reflect.Uint8 {
+ break
+ }
+ // [...]byte
var bytes []byte
if val.CanAddr() {
bytes = val.Slice(0, val.Len()).Bytes()
@@ -665,7 +668,10 @@
}
return "", bytes, nil
case reflect.Slice:
- // will be []byte
+ if typ.Elem().Kind() != reflect.Uint8 {
+ break
+ }
+ // []byte
return "", val.Bytes(), nil
}
return "", nil, &UnsupportedTypeError{typ}