summaryrefslogtreecommitdiff
path: root/borrowed_misc.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2022-08-14 20:52:06 -0600
committerLuke Shumaker <lukeshu@datawire.io>2022-08-16 00:05:24 -0600
commit54bbd1e59317a6e9658eb8098657078cc8e81979 (patch)
tree0d7033a0644945dedfe0fca158e0c40864f759f6 /borrowed_misc.go
parent2ae2ebe2a5ac712db6f9221cb1ad8cfa76aad180 (diff)
wip: Reduce test differences [ci-skip]
- Handle UTF-16 surrogate pairs - Handle cycles in values - Handle cycles in types - Better errors - Handle case-folding of struct field names - Allow []byteTypeWithMethods - Fix struct field-order - Fix handling of interfaces storing pointers - Enforce a maximum decode depth - Validate struct tags
Diffstat (limited to 'borrowed_misc.go')
-rw-r--r--borrowed_misc.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/borrowed_misc.go b/borrowed_misc.go
index 343c924..d5ace19 100644
--- a/borrowed_misc.go
+++ b/borrowed_misc.go
@@ -6,6 +6,8 @@ package lowmemjson
import (
"reflect"
+ "strings"
+ "unicode"
)
// from encode.go
@@ -26,3 +28,21 @@ func isEmptyValue(v reflect.Value) bool {
}
return false
}
+
+// 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
+}