json-repair 0.11.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/lib/json/repair/version.rb +1 -1
- data/lib/json/repairer.rb +16 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69085d74f416811c4ac11ca7cfe2e9545a6cecdaeb32de96532932c99ab4aaf3
|
|
4
|
+
data.tar.gz: 4deee8e6715200ae693144a2c8cab914b9e8c78c3b539671f7632ce39d7b77f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 31242bd165c070b1836d85a3fca120b5853a6e1ed715dbaeb75aa026563e033a7af491e318c119f3f3f899c4a7bb55382fc998372d7b55953358dc95d9c526be
|
|
7
|
+
data.tar.gz: b8a5a58a36d1c2b36922205f2b3b8d33e89e570fc215ed02ef288577a8d1325d96fa21cda9267ca78f44754b00a3150e5f6d149d6087c9f020e23090d47a13f2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
### 2026-06-12 (0.11.3)
|
|
4
|
+
|
|
5
|
+
* Fix infinite recursion (`SystemStackError`) on a quoted string
|
|
6
|
+
followed by a backslash-escaped delimiter, like `["y"\, "z"]`. The
|
|
7
|
+
missing-end-quote retry in `parse_string` stops at the comma it
|
|
8
|
+
detected in the first pass, but the invalid-escape repair consumed
|
|
9
|
+
`\,` as one two-character step, jumping over the stop index and
|
|
10
|
+
re-firing the retry with identical arguments forever — violating the
|
|
11
|
+
contract that `JSONRepairError` is the only error raised. The escaped
|
|
12
|
+
delimiter now ends the string there and the dangling backslash is
|
|
13
|
+
dropped (the standard invalid-escape repair): `["y"\, "z"]` →
|
|
14
|
+
`["y\"","z"]`. The stop-index check is also hardened from `==` to
|
|
15
|
+
`>=` so no future multi-character advance can step over it and
|
|
16
|
+
recurse. Deliberate divergence from upstream
|
|
17
|
+
[jsonrepair](https://github.com/josdejong/jsonrepair), which crashes
|
|
18
|
+
with "Maximum call stack size exceeded" on the same input as of
|
|
19
|
+
v3.14.0 (still its latest release). Found by differential fuzzing
|
|
20
|
+
during the 0.11.2 work and re-validated the same way: across a
|
|
21
|
+
240-input grid of escape-adjacent shapes, only previously-crashing
|
|
22
|
+
inputs changed behavior — object shapes like `{"k": "y"\, "z"}` now
|
|
23
|
+
raise the same "Colon expected" as their backslash-free analog
|
|
24
|
+
`{"k": "y", "z"}`. Benchmarks flat vs 0.11.2.
|
|
25
|
+
|
|
3
26
|
### 2026-06-12 (0.11.2)
|
|
4
27
|
|
|
5
28
|
* Fix the 0.11.0 doubled-colon repair silently mangling objects with a
|
data/lib/json/repair/version.rb
CHANGED
data/lib/json/repairer.rb
CHANGED
|
@@ -463,7 +463,13 @@ module JSON
|
|
|
463
463
|
return true
|
|
464
464
|
end
|
|
465
465
|
|
|
466
|
-
|
|
466
|
+
# >= with a sentinel guard, not ==. Divergence from upstream (which
|
|
467
|
+
# compares with == as of v3.14.0): a multi-character advance below
|
|
468
|
+
# can step over the stop index, and resuming the comma-path retry
|
|
469
|
+
# from beyond it would re-fire that retry with identical arguments
|
|
470
|
+
# forever. The invalid-escape repair below avoids the only known
|
|
471
|
+
# overshoot; this is the backstop guaranteeing termination.
|
|
472
|
+
if stop_at_index >= 0 && @index >= stop_at_index
|
|
467
473
|
# use the stop index detected in the first iteration, and repair end quote
|
|
468
474
|
str = insert_before_last_whitespace(str, '"')
|
|
469
475
|
@output << str
|
|
@@ -569,6 +575,15 @@ module JSON
|
|
|
569
575
|
# repair a backslash escaped newline (like in Bash scripts)
|
|
570
576
|
str << '\n'
|
|
571
577
|
@index += 2
|
|
578
|
+
elsif @index + 1 == stop_at_index
|
|
579
|
+
# repair invalid escape character: remove it — but the escaped
|
|
580
|
+
# character is the delimiter the comma-path retry said to stop
|
|
581
|
+
# at, so drop only the backslash and let the stop check above
|
|
582
|
+
# fire there, keeping the delimiter a delimiter. Divergence
|
|
583
|
+
# from upstream, which consumes both characters, jumps the stop
|
|
584
|
+
# index, and crashes ("Maximum call stack size exceeded" on
|
|
585
|
+
# inputs like `["y"\, "z"]` as of v3.14.0).
|
|
586
|
+
@index += 1
|
|
572
587
|
else
|
|
573
588
|
# repair invalid escape character: remove it
|
|
574
589
|
str << char
|