diff options
Diffstat (limited to 'vendor/github.com/bytedance/sonic/unquote')
| -rw-r--r-- | vendor/github.com/bytedance/sonic/unquote/unquote.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/vendor/github.com/bytedance/sonic/unquote/unquote.go b/vendor/github.com/bytedance/sonic/unquote/unquote.go index 0ffdaac7d..23fca736e 100644 --- a/vendor/github.com/bytedance/sonic/unquote/unquote.go +++ b/vendor/github.com/bytedance/sonic/unquote/unquote.go @@ -18,6 +18,7 @@ package unquote import ( `unsafe` + `runtime` `github.com/bytedance/sonic/internal/native` `github.com/bytedance/sonic/internal/native/types` @@ -43,7 +44,8 @@ func intoBytesUnsafe(s string, m *[]byte) types.ParsingError { pos := -1 slv := (*rt.GoSlice)(unsafe.Pointer(m)) str := (*rt.GoString)(unsafe.Pointer(&s)) - ret := native.Unquote(str.Ptr, str.Len, slv.Ptr, &pos, 0) + /* unquote as the default configuration, replace invalid unicode with \ufffd */ + ret := native.Unquote(str.Ptr, str.Len, slv.Ptr, &pos, types.F_UNICODE_REPLACE) /* check for errors */ if ret < 0 { @@ -52,5 +54,6 @@ func intoBytesUnsafe(s string, m *[]byte) types.ParsingError { /* update the length */ slv.Len = ret + runtime.KeepAlive(s) return 0 } |
