3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 06:35:44 +01:00

Round-trip JSON keys holding a backslash, quote or control character, and generate them in the properties

This commit is contained in:
2026-10-08 12:15:16 +02:00
committed by Lillem4n
parent 8d1c75fa8b
commit bfe26dd438
4 changed files with 68 additions and 14 deletions
+1 -4
View File
@@ -43,10 +43,7 @@ const numberValue = fc.oneof(
{ arbitrary: fc.constant(-0), weight: 1 },
)
// V8's JSON.parse returns a wrong key after parsing a key holding an escaped backslash (https://issues.chromium.org/issues/521080746); Bun is unaffected.
const keyPiece = fc
.oneof({ arbitrary: markdownPieces, weight: 4 }, { arbitrary: fc.string({ maxLength: 1, minLength: 1, unit: 'grapheme' }), weight: 1 })
.filter((piece) => !/[\\"\x00-\x1f]/.test(piece))
const keyPiece = fc.oneof({ arbitrary: markdownPieces, weight: 4 }, { arbitrary: fc.string({ maxLength: 1, minLength: 1, unit: 'grapheme' }), weight: 1 })
export const jsonKey = fc.string({ maxLength: 8, unit: keyPiece })
export const { jsonValue } = fc.letrec<{ jsonValue: JsonValue }>((tie) => ({