mirror of
https://github.com/golang/go.git
synced 2025-11-08 04:31:01 +00:00
encoding/json: allow punctuation in tag names
everything except backslash and the quote chars is fair game. Fixes #3546. R=rsc, r CC=golang-dev https://golang.org/cl/6048047
This commit is contained in:
parent
b252fe7002
commit
52f122d72e
2 changed files with 11 additions and 3 deletions
|
|
@ -17,6 +17,7 @@ import (
|
|||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
|
@ -415,9 +416,11 @@ func isValidTag(s string) bool {
|
|||
return false
|
||||
}
|
||||
for _, c := range s {
|
||||
switch c {
|
||||
case '$', '-', '_', '/', '%':
|
||||
// Acceptable
|
||||
switch {
|
||||
case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~", c):
|
||||
// Backslash and quote chars are reserved, but
|
||||
// otherwise any punctuation chars are allowed
|
||||
// in a tag name.
|
||||
default:
|
||||
if !unicode.IsLetter(c) && !unicode.IsDigit(c) {
|
||||
return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue