json 3.0.2 → 3.2.0

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: 8462d78f66ef2dde1fbece04f33a916b97b753e1593af7ffbe27113199fe6078
4
- data.tar.gz: 27509e760c57f937fe6e6278eebd7989d160e5779b9fce498b0afb9451de54d3
3
+ metadata.gz: dfa0b8944bdc1b1430778f602a291f704d6a127069ba231a511d9493f251aa91
4
+ data.tar.gz: c78507e03c6327dabda8a08a3c821217fb2e2509344ef3d48fb2dfb1ad734ebc
5
5
  SHA512:
6
- metadata.gz: 6414753f43c5b3a7b97405acc7c7a732468eb0648e560eb472f04cc3880f933e5138b4dfe6af81893683603dcf511c7051dcb74ef5b8631c30a50e236ac88408
7
- data.tar.gz: e05816e7fbdd58ab2e18cb2cee29d4354087de200f24ece9e348f05b979e62f6d69a0ab6b60ddabaf3d6cef0d0b5e00e0c0499dbdc608ddb49fc6b4d374f681c
6
+ metadata.gz: 2a64146f23831a94b36b2bbe194d275f8e169237cac77ec47614342dbc53ee5e467bd41fb87a1a71031ca6aecc83f023f96acad719ecb6c91c8877644332a458
7
+ data.tar.gz: 947a6b55a76493981309be2e3b3f79bb60afe7d4c8db76ee1855023faf66e96dc099238f273ad9fad01c19b2e53d2d23f1d20b55880ab5f268b026c869aa738d
data/CHANGES.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
+ ### 2026-11-24 (3.2.0)
6
+
7
+ * The `script_safe: true` option of `JSON.generate` no longer escapes forward slashes `/`, and instead escapes script tag
8
+ openings (`<script`), script tag closing (`</script`) and HTML comments (`<!--`) as recommended by the HTML spec.
9
+ * The `script_safe: true` option of `JSON.generate` no longer escapes `U+2028` and `U+2029` given that Javascript is
10
+ now a proper subset of JSON since many years (see: https://github.com/tc39/proposal-json-superset).
11
+ * Fix `JSON::ParserError#json_path` raising `NoMethodError` when the document was parsed with `symbolize_names: true`.
12
+ * Fix `JSON.generate` not detecting duplicate keys such as `{ "1" => 1, 1 => 2 }`.
13
+ * JRuby: raise `TypeError` when a String subclass used as a Hash key has a `to_s` that doesn't return a String, like the C extension.
14
+ * JRuby and TruffleRuby: fix a stack overflow in `JSON::Coder` when `as_json` returns a Symbol for a string with invalid encoding.
15
+ * JRuby: fix `JSON::Coder` (and any frozen `JSON::State`) not being thread-safe. Each `#dump` call now uses its own nesting depth instead of mutating the shared state, which under concurrent use could make every later call raise `JSON::NestingError`.
16
+
17
+ ### 2026-10-13 (3.1.0)
18
+
19
+ * Added `rfc8785` generator option to canonicalize the output. Replaces the `json-canonicalization` with numerous correctness fixes.
20
+ * Use the `rb_len_t` type introduced in Ruby 4.1 to allow for proper 64bit support on LP64 platforms (Windows).
21
+ * JRuby: parser errors now include the position (`line`, `column` and the message suffix) as well as `json_path`, matching the C extension.
22
+ * Improved the accuracy of parser error's `line`, `column` and snipets in presence of multibyte characters.
23
+ * Fix `JSON.load` to work correctly when provided a `Zlib::GzipReader` as IO source.
24
+ * Reject non-ASCII BINARY strings during JSON generation. This was deprecated since a long time and scheduled to be removed for 3.0.
25
+
5
26
  ### 2026-09-09 (3.0.2)
6
27
 
7
28
  * Fix `JSON.load_file` and `JSON.load_file!` to load on Ruby 2.7.0 through 2.7.2, which cannot parse a leading parameter before `...`.
@@ -129,6 +150,15 @@ Numerous rarely used aliases have been removed.
129
150
  * Fix `allow_blank` parsing option to no longer allow invalid types (e.g. `load([], allow_blank: true)` now raise a type error).
130
151
  * Add `allow_invalid_escape` parsing option to ignore backslashes that aren't followed by one of the valid escape characters.
131
152
 
153
+ ### 2026-11-13 (2.18.3)
154
+
155
+ * Backport format string injection fix from 2.19.2. `CVE-2026-33210` / GHSA-3m6g-2423-7cp3.
156
+
157
+ ### 2026-11-02 (2.18.2)
158
+
159
+ * Backport handling of unescaped control characters preceeded by a backslash from 2.19.3.
160
+ GHSA-cjpr-jw2g-fw99.
161
+
132
162
  ### 2026-02-03 (2.18.1)
133
163
 
134
164
  * Fix a potential crash in very specific circumstance if GC triggers during a call to `to_json`
@@ -33,7 +33,7 @@ typedef struct FBufferStruct {
33
33
  static void fbuffer_free(FBuffer *fb);
34
34
  static void fbuffer_clear(FBuffer *fb);
35
35
  static void fbuffer_append(FBuffer *fb, const char *newstr, size_t len);
36
- static void fbuffer_append_long(FBuffer *fb, long number);
36
+ static void fbuffer_append_len(FBuffer *fb, rb_len_t number);
37
37
  static inline void fbuffer_append_char(FBuffer *fb, char newchr);
38
38
  static VALUE fbuffer_finalize(FBuffer *fb);
39
39
 
@@ -169,6 +169,10 @@ static inline void fbuffer_append_reserved_char(FBuffer *fb, char chr)
169
169
 
170
170
  static void fbuffer_append_str(FBuffer *fb, VALUE str)
171
171
  {
172
+ if (RB_UNLIKELY(fb->io)) {
173
+ // Growing the buffer may flush it and invoke arbitrary Ruby code.
174
+ str = rb_str_new_frozen(str);
175
+ }
172
176
  const char *ptr;
173
177
  size_t len;
174
178
  RSTRING_GETMEM(str, ptr, len);
@@ -214,7 +218,7 @@ static inline void fbuffer_advance_to(FBuffer *fb, char *end)
214
218
  /*
215
219
  * Appends the decimal string representation of \a number into the buffer.
216
220
  */
217
- static void fbuffer_append_long(FBuffer *fb, long number)
221
+ static void fbuffer_append_len(FBuffer *fb, rb_len_t number)
218
222
  {
219
223
  /*
220
224
  * The jeaiii_ultoa() function produces digits left-to-right,
@@ -227,9 +231,9 @@ static void fbuffer_append_long(FBuffer *fb, long number)
227
231
  * generated is therefore 20 (including a potential sign character).
228
232
  */
229
233
 
230
- static const int MAX_CHARS_FOR_LONG = 20;
234
+ static const int MAX_CHARS_FOR_LEN = 20;
231
235
 
232
- fbuffer_inc_capa(fb, MAX_CHARS_FOR_LONG);
236
+ fbuffer_inc_capa(fb, MAX_CHARS_FOR_LEN);
233
237
 
234
238
  if (number < 0) {
235
239
  fbuffer_append_reserved_char(fb, '-');