forked from mirror/go-json
Merge pull request #102 from goccy/feature/fix-decoding-escaped-char
Fix decoding of escape char at UnmarshalJSON
This commit is contained in:
commit
c655881253
|
@ -218,6 +218,7 @@ func (d *interfaceDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (i
|
||||||
switch buf[cursor] {
|
switch buf[cursor] {
|
||||||
case '\\':
|
case '\\':
|
||||||
cursor++
|
cursor++
|
||||||
|
continue
|
||||||
case '"':
|
case '"':
|
||||||
literal := buf[start:cursor]
|
literal := buf[start:cursor]
|
||||||
cursor++
|
cursor++
|
||||||
|
|
|
@ -226,6 +226,14 @@ func Test_Decoder(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue98(t *testing.T) {
|
||||||
|
data := "[\"\\"
|
||||||
|
var v interface{}
|
||||||
|
if err := json.Unmarshal([]byte(data), &v); err == nil {
|
||||||
|
t.Fatal("expected error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Test_Decoder_UseNumber(t *testing.T) {
|
func Test_Decoder_UseNumber(t *testing.T) {
|
||||||
dec := json.NewDecoder(strings.NewReader(`{"a": 3.14}`))
|
dec := json.NewDecoder(strings.NewReader(`{"a": 3.14}`))
|
||||||
dec.UseNumber()
|
dec.UseNumber()
|
||||||
|
|
Loading…
Reference in New Issue