From fa5c5043bca5264fabbdc47d780cfb53b1f5d9a3 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Sat, 11 Sep 2021 06:50:06 -0700 Subject: encoding/xml: truncate generic type names xml names can't have any of '[],' in them, which might appear in generic type names. Truncate at the first '[' so the names are still valid. Fixes #48318 Change-Id: I110ff4269f763089467e7cf84b0f0c5075fb44b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/349349 Trust: Keith Randall Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Russ Cox --- src/encoding/xml/marshal.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/encoding/xml') diff --git a/src/encoding/xml/marshal.go b/src/encoding/xml/marshal.go index d8a04a95a2..a8c8f659ca 100644 --- a/src/encoding/xml/marshal.go +++ b/src/encoding/xml/marshal.go @@ -494,6 +494,10 @@ func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo, startTemplat } if start.Name.Local == "" { name := typ.Name() + if i := strings.IndexByte(name, '['); i >= 0 { + // Truncate generic instantiation name. See issue 48318. + name = name[:i] + } if name == "" { return &UnsupportedTypeError{typ} } -- cgit v1.3