Skip to content

Commit e3dbacc

Browse files
committed
fix(json): bug when \uxxxx is first escaping sequence in a string
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
1 parent 1603a7d commit e3dbacc

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

internal/json/lex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ str:
311311
if j.remain() >= 5 {
312312
r, ok = hex(j.buf[j.pos.bpos+1 : j.pos.bpos+5])
313313
if ok {
314-
j.pos = j.pos.incHoriz(4)
315314
appendBuffer(r)
315+
j.pos = j.pos.incHoriz(4)
316316
break
317317
}
318318
}

internal/json/parser_test.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,27 @@ func TestJSON(t *testing.T) {
3535
`0`,
3636
`""`,
3737
`"123.456$"`,
38-
` "foo bar \" \\ \/ \b \f \n\r \t \u10e6 \u10E6 héhô" `,
38+
` "foo bar \" \\ \/ \b \f \n\r \t \u20ac \u10e6 \u10E6 héhô" `,
39+
`"\""`,
40+
`"\\"`,
41+
`"\/"`,
42+
`"\b"`,
43+
`"\f"`,
44+
`"\n"`,
45+
`"\r"`,
46+
`"\t"`,
47+
`"\u20ac"`,
48+
`"zz\""`,
49+
`"zz\\"`,
50+
`"zz\/"`,
51+
`"zz\b"`,
52+
`"zz\f"`,
53+
`"zz\n"`,
54+
`"zz\r"`,
55+
`"zz\t"`,
56+
`"zz\u20ac"`,
57+
`["74.99 \u20ac"]`,
58+
`{"text": "74.99 \u20ac"}`,
3959
`[ 1, 2,3, 4 ]`,
4060
`{"foo":{"bar":true},"zip":1234}`,
4161
} {

0 commit comments

Comments
 (0)