json-repair 0.11.0 → 0.11.1

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: 0c130bbea1b9299e31e5bfa8db873b09fd911715b7125fda6ee60a101353be5f
4
- data.tar.gz: 80f6e2fe16669210505e45c99a443eaa3ce6b8b3c10e3967633885f91a9d057b
3
+ metadata.gz: 288e3502829f51d11dbf2c3a9ab45f04dd44a1fa9ae5e00c1537f47c215aad96
4
+ data.tar.gz: 1ab99e5121ef3e73066157569bd85379a527cc1f44ecd7087d4f058133c4fcf0
5
5
  SHA512:
6
- metadata.gz: 4e2c05c45ebf1cf149705021faa611c22e6e2e0de48d15d2496da4e935291abe6bf185cde756263c6aad210f73ca2e54e4c965826b14bdbb0fa9ffa47bf1684f
7
- data.tar.gz: 180b477cea0b27c813b664bfcda75eb28b59453d1fe4ce90781cf298c870aa8518411e689a37ddc30882aa5f376c351ff718600411d97df845f67fd87b593d92
6
+ metadata.gz: ffc4cd085d9a6aa5b45f3ee605a0fa043e20c68d63fdaab5c736acecbb17f160066d4412a76496300614545577d74d5ca4b232d4354adf625913753f8c0e8477
7
+ data.tar.gz: 190ea601a010b401fdf0c6aa52670a030ce81d39ebcd1af1f81c9fb2399baf6d074f3135b3b05814d1bcfcd24db53321a779b760c8eebe8d5a9ce2e029476754
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changes
2
2
 
3
+ ### 2026-06-12 (0.11.1)
4
+
5
+ * Fix a `TypeError` crash on input ending in a lone backslash inside a
6
+ string: `"abc\` now repairs to `"abc"` (likewise `"\` → `""`,
7
+ `["abc\` → `["abc"]`, `{"a": "b\` → `{"a":"b"}`), matching upstream
8
+ [jsonrepair](https://github.com/josdejong/jsonrepair) v3.14.0. This
9
+ was a porting bug — JS `charAt` past EOF returns `''` where Ruby
10
+ `String#[]` returns `nil`, so the invalid-escape repair in
11
+ `parse_string` crashed on `str << nil` instead of ending the string,
12
+ violating the contract that `JSONRepairError` is the only error
13
+ raised. Found by differential fuzzing during the 0.11.0 review.
14
+
3
15
  ### 2026-06-12 (0.11.0)
4
16
 
5
17
  * Repair object string values with unescaped quotes around a colon
data/CLAUDE.md CHANGED
@@ -14,7 +14,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
14
14
  - `bundle exec rake install` / `bundle exec rake release` — local install / publish to rubygems.org (release prompts for a rubygems MFA OTP).
15
15
  - Type checking: `Steepfile` checks `lib/` against `sig/`. `bundle exec steep check` (typecheck) and `bundle exec rbs validate` (sig syntax) both run in CI and as part of the default rake task. `steep` and `rbs` are dev dependencies in the `Gemfile`.
16
16
 
17
- Ruby `>= 3.0.0` is required (per gemspec). CI runs against Ruby 3.3.1.
17
+ Ruby `>= 3.0.0` is required (per gemspec). CI runs against all currently maintained Ruby branches (3.3, 3.4, 4.0).
18
18
 
19
19
  ## Architecture
20
20
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JSON
4
4
  module Repair
5
- VERSION = '0.11.0'
5
+ VERSION = '0.11.1'
6
6
  end
7
7
  end
data/lib/json/repairer.rb CHANGED
@@ -68,7 +68,7 @@ module JSON
68
68
  end
69
69
 
70
70
  # repair redundant end quotes
71
- while @json[@index] == CLOSING_BRACE || @json[@index] == CLOSING_BRACKET
71
+ while [CLOSING_BRACE, CLOSING_BRACKET].include?(@json[@index])
72
72
  @index += 1
73
73
  parse_whitespace_and_skip_comments
74
74
  end
@@ -236,7 +236,6 @@ module JSON
236
236
 
237
237
  initial = true
238
238
  while @index < @json.length && @json[@index] != CLOSING_BRACE
239
- processed_comma = true
240
239
  if initial
241
240
  initial = false
242
241
  else
@@ -531,7 +530,9 @@ module JSON
531
530
  return true
532
531
  elsif @json[@index] == BACKSLASH
533
532
  # handle escaped content like \n or ★
534
- char = @json[@index + 1]
533
+ # nil at EOF: '' mirrors JS charAt, making the invalid-escape
534
+ # repair below a no-op that ends the string
535
+ char = @json[@index + 1] || ''
535
536
  escape_char = ESCAPE_CHARACTERS[char]
536
537
  if escape_char
537
538
  str << @json[@index, 2]
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.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksandr Zykov