diff options
author | 2024-05-06 08:50:47 +0000 | |
---|---|---|
committer | 2024-05-06 08:50:47 +0000 | |
commit | a5f28fe0c923984c263592e82bbce99b0032b794 (patch) | |
tree | 403544ad5305eb171a85d2b4c59559f83abd87a7 /vendor/github.com/bytedance/sonic/ast/api_compat.go | |
parent | [chore]: Bump golang.org/x/image from 0.15.0 to 0.16.0 (#2898) (diff) | |
download | gotosocial-a5f28fe0c923984c263592e82bbce99b0032b794.tar.xz |
[chore]: Bump github.com/gin-contrib/gzip from 1.0.0 to 1.0.1 (#2899)
Bumps [github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/gin-contrib/gzip/releases)
- [Changelog](https://github.com/gin-contrib/gzip/blob/master/.goreleaser.yaml)
- [Commits](https://github.com/gin-contrib/gzip/compare/v1.0.0...v1.0.1)
---
updated-dependencies:
- dependency-name: github.com/gin-contrib/gzip
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/bytedance/sonic/ast/api_compat.go')
-rw-r--r-- | vendor/github.com/bytedance/sonic/ast/api_compat.go | 91 |
1 files changed, 50 insertions, 41 deletions
diff --git a/vendor/github.com/bytedance/sonic/ast/api_compat.go b/vendor/github.com/bytedance/sonic/ast/api_compat.go index 2c889fc2a..82d1eacd3 100644 --- a/vendor/github.com/bytedance/sonic/ast/api_compat.go +++ b/vendor/github.com/bytedance/sonic/ast/api_compat.go @@ -19,67 +19,69 @@ package ast import ( - `encoding/json` + `encoding/json` + `unicode/utf8` - `github.com/bytedance/sonic/internal/native/types` - `github.com/bytedance/sonic/internal/rt` + `github.com/bytedance/sonic/internal/native/types` + `github.com/bytedance/sonic/internal/rt` ) func init() { - println("WARNING:(ast) sonic only supports Go1.16~1.22, but your environment is not suitable") + println("WARNING:(ast) sonic only supports Go1.16~1.22, but your environment is not suitable") } func quote(buf *[]byte, val string) { - quoteString(buf, val) + quoteString(buf, val) } +// unquote unescapes a internal JSON string (it doesn't count quotas at the begining and end) func unquote(src string) (string, types.ParsingError) { - sp := rt.IndexChar(src, -1) - out, ok := unquoteBytes(rt.BytesFrom(sp, len(src)+2, len(src)+2)) - if !ok { - return "", types.ERR_INVALID_ESCAPE - } - return rt.Mem2Str(out), 0 + sp := rt.IndexChar(src, -1) + out, ok := unquoteBytes(rt.BytesFrom(sp, len(src)+2, len(src)+2)) + if !ok { + return "", types.ERR_INVALID_ESCAPE + } + return rt.Mem2Str(out), 0 } func (self *Parser) decodeValue() (val types.JsonState) { - e, v := decodeValue(self.s, self.p, self.dbuf == nil) - if e < 0 { - return v - } - self.p = e - return v + e, v := decodeValue(self.s, self.p, self.dbuf == nil) + if e < 0 { + return v + } + self.p = e + return v } func (self *Parser) skip() (int, types.ParsingError) { - e, s := skipValue(self.s, self.p) - if e < 0 { - return self.p, types.ParsingError(-e) - } - self.p = e - return s, 0 + e, s := skipValue(self.s, self.p) + if e < 0 { + return self.p, types.ParsingError(-e) + } + self.p = e + return s, 0 } func (self *Parser) skipFast() (int, types.ParsingError) { - e, s := skipValueFast(self.s, self.p) - if e < 0 { - return self.p, types.ParsingError(-e) - } - self.p = e - return s, 0 + e, s := skipValueFast(self.s, self.p) + if e < 0 { + return self.p, types.ParsingError(-e) + } + self.p = e + return s, 0 } func (self *Node) encodeInterface(buf *[]byte) error { - out, err := json.Marshal(self.packAny()) - if err != nil { - return err - } - *buf = append(*buf, out...) - return nil + out, err := json.Marshal(self.packAny()) + if err != nil { + return err + } + *buf = append(*buf, out...) + return nil } -func (self *Parser) getByPath(path ...interface{}) (int, types.ParsingError) { +func (self *Parser) getByPath(validate bool, path ...interface{}) (int, types.ParsingError) { for _, p := range path { if idx, ok := p.(int); ok && idx >= 0 { if err := self.searchIndex(idx); err != 0 { @@ -93,13 +95,20 @@ func (self *Parser) getByPath(path ...interface{}) (int, types.ParsingError) { panic("path must be either int(>=0) or string") } } - start, e := self.skip() + + var start int + var e types.ParsingError + if validate { + start, e = self.skip() + } else { + start, e = self.skipFast() + } if e != 0 { return self.p, e } - // t := switchRawType(self.s[start]) - // if t == _V_NUMBER { - // self.p = 1 + backward(self.s, self.p-1) - // } return start, 0 } + +func validate_utf8(str string) bool { + return utf8.ValidString(str) +} |