summaryrefslogtreecommitdiff
path: root/internal/jsonstruct/borrowed_misc.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-02-07 14:06:12 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-02-07 14:06:12 -0700
commit480ccfd05a13ac36516c536a71203280a31b4d28 (patch)
tree4ae21bf95c9f3b4cce97a0a0473fe622fdb393eb /internal/jsonstruct/borrowed_misc.go
parent87013d526ea1b0647ef6e08758fe587cee11d854 (diff)
parent47549aa3d10808c063d45dcaa598887dadde59c5 (diff)
Merge branch 'lukeshu/fixup'
Diffstat (limited to 'internal/jsonstruct/borrowed_misc.go')
-rw-r--r--internal/jsonstruct/borrowed_misc.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/jsonstruct/borrowed_misc.go b/internal/jsonstruct/borrowed_misc.go
new file mode 100644
index 0000000..3b4181e
--- /dev/null
+++ b/internal/jsonstruct/borrowed_misc.go
@@ -0,0 +1,30 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+//
+// SPDX-License-Identifier: BSD-3-Clause
+
+package jsonstruct
+
+import (
+ "strings"
+ "unicode"
+)
+
+// isValidTag is borrowed from encode.go.
+func isValidTag(s string) bool {
+ if s == "" {
+ return false
+ }
+ for _, c := range s {
+ switch {
+ case strings.ContainsRune("!#$%&()*+-./:;<=>?@[]^_{|}~ ", c):
+ // Backslash and quote chars are reserved, but
+ // otherwise any punctuation chars are allowed
+ // in a tag name.
+ case !unicode.IsLetter(c) && !unicode.IsDigit(c):
+ return false
+ }
+ }
+ return true
+}