forked from mirror/sjson
Ensure backslashes are always escaped
This commit is contained in:
parent
dc363de894
commit
82a6448692
2
sjson.go
2
sjson.go
|
@ -108,7 +108,7 @@ func parsePath(path string) (pathResult, error) {
|
|||
|
||||
func mustMarshalString(s string) bool {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] < ' ' || s[i] > 0x7f || s[i] == '"' || (s[i] == '\\' && i == len(s)-1) {
|
||||
if s[i] < ' ' || s[i] > 0x7f || s[i] == '"' || s[i] == '\\' {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ func TestBasic(t *testing.T) {
|
|||
``,
|
||||
"\\:1.this.4", `4`)
|
||||
testRaw(t, setRaw,
|
||||
`{":\1":{"this":[null,null,null,null,{".HI":4}]}}`,
|
||||
`{":\\1":{"this":[null,null,null,null,{".HI":4}]}}`,
|
||||
``,
|
||||
"\\:\\\\1.this.4.\\.HI", `4`)
|
||||
testRaw(t, setRaw,
|
||||
|
|
Loading…
Reference in New Issue