aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json
diff options
context:
space:
mode:
authorSean Liao <seankhliao@gmail.com>2020-05-21 17:52:33 +0200
committerDaniel Martí <mvdan@mvdan.cc>2020-09-24 18:05:54 +0000
commit25a33daa2b7e7bda773705215113450923ae4815 (patch)
tree07830a8c17817e748369a6f6aa91bc919166c331 /src/encoding/json
parent0f55d37d440d83f206bfc00b4a2521c1a0bb258b (diff)
downloadgo-25a33daa2b7e7bda773705215113450923ae4815.tar.gz
go-25a33daa2b7e7bda773705215113450923ae4815.zip
encoding/json: allow semicolon in field key / struct tag
Allow ';' as a valid character for json field keys and struct tags. Fixes #39189 Change-Id: I4b602a1b0674ff028db07623682f0d1e8e9fd6c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/234818 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Go Bot <gobot@golang.org> Trust: Giovanni Bajo <rasky@develer.com> Trust: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Diffstat (limited to 'src/encoding/json')
-rw-r--r--src/encoding/json/encode.go2
-rw-r--r--src/encoding/json/tagkey_test.go4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go
index 578d551102..c2d191442c 100644
--- a/src/encoding/json/encode.go
+++ b/src/encoding/json/encode.go
@@ -946,7 +946,7 @@ func isValidTag(s string) bool {
}
for _, c := range s {
switch {
- case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c):
+ case strings.ContainsRune("!#$%&()*+-./:;<=>?@[]^_{|}~ ", c):
// Backslash and quote chars are reserved, but
// otherwise any punctuation chars are allowed
// in a tag name.
diff --git a/src/encoding/json/tagkey_test.go b/src/encoding/json/tagkey_test.go
index f77c49c764..bbb4e6a28d 100644
--- a/src/encoding/json/tagkey_test.go
+++ b/src/encoding/json/tagkey_test.go
@@ -41,7 +41,7 @@ type percentSlashTag struct {
}
type punctuationTag struct {
- V string `json:"!#$%&()*+-./:<=>?@[]^_{|}~"` // https://golang.org/issue/3546
+ V string `json:"!#$%&()*+-./:;<=>?@[]^_{|}~ "` // https://golang.org/issue/3546
}
type dashTag struct {
@@ -90,7 +90,7 @@ var structTagObjectKeyTests = []struct {
{badFormatTag{"Orfevre"}, "Orfevre", "Y"},
{badCodeTag{"Reliable Man"}, "Reliable Man", "Z"},
{percentSlashTag{"brut"}, "brut", "text/html%"},
- {punctuationTag{"Union Rags"}, "Union Rags", "!#$%&()*+-./:<=>?@[]^_{|}~"},
+ {punctuationTag{"Union Rags"}, "Union Rags", "!#$%&()*+-./:;<=>?@[]^_{|}~ "},
{spaceTag{"Perreddu"}, "Perreddu", "With space"},
{unicodeTag{"Loukanikos"}, "Loukanikos", "Ελλάδα"},
}