aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/xml/marshal.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-10-28 09:12:20 -0400
committerCherry Zhang <cherryyz@google.com>2020-10-28 09:12:20 -0400
commita16e30d162c1c7408db7821e7b9513cefa09c6ca (patch)
treeaf752ba9ba44c547df39bb0af9bff79f610ba9d5 /src/encoding/xml/marshal.go
parent91e4d2d57bc341dd82c98247117114c851380aef (diff)
parentcf6cfba4d5358404dd890f6025e573a4b2156543 (diff)
downloadgo-a16e30d162c1c7408db7821e7b9513cefa09c6ca.tar.gz
go-a16e30d162c1c7408db7821e7b9513cefa09c6ca.zip
[dev.link] all: merge branch 'master' into dev.linkdev.link
Clean merge. Change-Id: Ia7b2808bc649790198d34c226a61d9e569084dc5
Diffstat (limited to 'src/encoding/xml/marshal.go')
-rw-r--r--src/encoding/xml/marshal.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/encoding/xml/marshal.go b/src/encoding/xml/marshal.go
index 0554b0d204..d8a04a95a2 100644
--- a/src/encoding/xml/marshal.go
+++ b/src/encoding/xml/marshal.go
@@ -345,8 +345,11 @@ func (p *printer) createAttrPrefix(url string) string {
if prefix == "" || !isName([]byte(prefix)) || strings.Contains(prefix, ":") {
prefix = "_"
}
- if strings.HasPrefix(prefix, "xml") {
- // xmlanything is reserved.
+ // xmlanything is reserved and any variant of it regardless of
+ // case should be matched, so:
+ // (('X'|'x') ('M'|'m') ('L'|'l'))
+ // See Section 2.3 of https://www.w3.org/TR/REC-xml/
+ if len(prefix) >= 3 && strings.EqualFold(prefix[:3], "xml") {
prefix = "_" + prefix
}
if p.attrNS[prefix] != "" {