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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d7b2f30c2451f62471beabed342ff8360f644e4ae703fa3e0f5490e44d4f0d1
4
- data.tar.gz: 254abaa4ab104a0cc6650d02f099ebb00b0600ef213b00866da266159b6c1a37
3
+ metadata.gz: 69085d74f416811c4ac11ca7cfe2e9545a6cecdaeb32de96532932c99ab4aaf3
4
+ data.tar.gz: 4deee8e6715200ae693144a2c8cab914b9e8c78c3b539671f7632ce39d7b77f3
5
5
  SHA512:
6
- metadata.gz: bfd417574888a7ff44a03870f48ab6e02c7bb7ae80189262e093425ba52e3943982f6ab36170c1cac6a3871e3d3379469b8319bbaa6defe8a0d473a7be6fe2a9
7
- data.tar.gz: 208611ef2a09d4e3a5c91afe98334dfc7443a3db56de9624cfa82a3dea1e0c0480de18227646a96dac3c46f64af526e229f70dd9de4cd41cc1160a703b132a0b
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JSON
4
4
  module Repair
5
- VERSION = '0.11.2'
5
+ VERSION = '0.11.3'
6
6
  end
7
7
  end
data/lib/json/repairer.rb CHANGED
@@ -463,7 +463,13 @@ module JSON
463
463
  return true
464
464
  end
465
465
 
466
- if @index == stop_at_index
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-repair
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksandr Zykov