json 2.18.1 → 2.19.5

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: cb2890db4c527125d27bc7c21fc64d3ac532ffbec8080f89a678daf48c36e09e
4
- data.tar.gz: c4b37d085d05d3c43df97b3c24898dc6be61c76ba64c749b5a8a86bf4fc1198d
3
+ metadata.gz: 0bbb85e1521c171ca73ab935cc00899ff3eb7086921a64542a3937fa9589848d
4
+ data.tar.gz: 328853f7f164d91522d6791a51cca5ccb3ae418410752a3fb72189bc14c157d5
5
5
  SHA512:
6
- metadata.gz: fb55ef5a0aa6961ef0fe3bb30f398834820357045ad27a8fdb7e53eaba3af7c4d356ef26c0e73b7a87d2d9d51e500eae7193d7d1ae3aa1058c7973bcc462674b
7
- data.tar.gz: bfb499789bbcee7f5f8d67e32ded664dc62c632ae39fe80bf4bff3d6aec16eee3730a7c4883216a393326f2ab33e94e5f9c58da4c5b31627347108c36c2b211c
6
+ metadata.gz: 326b0621e562eebc66f155cee358ca295dde7584e7f60268a354da3e8a1a02e13bfcd9fef7f9b2f9f2ea196987b07bb9e50578347231f14d9fb0e863ac9445ac
7
+ data.tar.gz: 0e9e2ab4c91b5544ac8440613a0fd63aab2f7b7ce5a39f41e786af736e80ca28de8d3388057134dde05ba53f4f150d24aa1a8cde92dac82abbb4104740409631
data/CHANGES.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
+ ### 2026-05-04 (2.19.5)
6
+
7
+ * Cap the parser to emit a maximum of 5 deprecation warnings per document. Emitting more is not helpful.
8
+
9
+ ### 2026-04-19 (2.19.4)
10
+
11
+ * Fix parsing of out of range floats (very large exponents that lead to either `0.0` or `Inf`).
12
+
13
+ ### 2026-03-25 (2.19.3)
14
+
15
+ * Fix handling of unescaped control characters preceeded by a backslash.
16
+
17
+ ### 2026-03-18 (2.19.2)
18
+
19
+ * Fix a format string injection vulnerability in `JSON.parse(doc, allow_duplicate_key: false)`. `CVE-2026-33210`.
20
+
21
+ ### 2026-03-08 (2.19.1)
22
+
23
+ * Fix a compiler dependent GC bug introduced in `2.18.0`.
24
+
25
+ ### 2026-03-06 (2.19.0)
26
+
27
+ * Fix `allow_blank` parsing option to no longer allow invalid types (e.g. `load([], allow_blank: true)` now raise a type error).
28
+ * Add `allow_invalid_escape` parsing option to ignore backslashes that aren't followed by one of the valid escape characters.
29
+
5
30
  ### 2026-02-03 (2.18.1)
6
31
 
7
32
  * Fix a potential crash in very specific circumstance if GC triggers during a call to `to_json`
@@ -11,6 +36,10 @@
11
36
 
12
37
  * Add `:allow_control_characters` parser options, to allow JSON strings containing unescaped ASCII control characters (e.g. newlines).
13
38
 
39
+ ### 2026-03-18 (2.17.1.2) - Security Backport
40
+
41
+ * Fix a format string injection vulnerability in `JSON.parse(doc, allow_duplicate_key: false)`. `CVE-2026-33210`.
42
+
14
43
  ### 2025-12-04 (2.17.1)
15
44
 
16
45
  * Fix a regression in parsing of unicode surogate pairs (`\uXX\uXX`) that could cause an invalid string to be returned.
@@ -37,6 +66,10 @@
37
66
  * Optimized numbers parsing using SWAR (thanks to Scott Myron).
38
67
  * Optimized parsing of pretty printed documents using SWAR (thanks to Scott Myron).
39
68
 
69
+ ### 2026-03-18 (2.15.2.1) - Security Backport
70
+
71
+ * Fix a format string injection vulnerability in `JSON.parse(doc, allow_duplicate_key: false)`. `CVE-2026-33210`.
72
+
40
73
  ### 2025-10-25 (2.15.2)
41
74
 
42
75
  * Fix `JSON::Coder` to have one dedicated depth counter per invocation.
@@ -11,11 +11,11 @@ enum fbuffer_type {
11
11
 
12
12
  typedef struct FBufferStruct {
13
13
  enum fbuffer_type type;
14
- unsigned long initial_length;
15
- unsigned long len;
16
- unsigned long capa;
14
+ size_t initial_length;
15
+ size_t len;
16
+ size_t capa;
17
17
  #if JSON_DEBUG
18
- unsigned long requested;
18
+ size_t requested;
19
19
  #endif
20
20
  char *ptr;
21
21
  VALUE io;
@@ -32,12 +32,12 @@ typedef struct FBufferStruct {
32
32
 
33
33
  static void fbuffer_free(FBuffer *fb);
34
34
  static void fbuffer_clear(FBuffer *fb);
35
- static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len);
35
+ static void fbuffer_append(FBuffer *fb, const char *newstr, size_t len);
36
36
  static void fbuffer_append_long(FBuffer *fb, long number);
37
37
  static inline void fbuffer_append_char(FBuffer *fb, char newchr);
38
38
  static VALUE fbuffer_finalize(FBuffer *fb);
39
39
 
40
- static void fbuffer_stack_init(FBuffer *fb, unsigned long initial_length, char *stack_buffer, long stack_buffer_size)
40
+ static void fbuffer_stack_init(FBuffer *fb, size_t initial_length, char *stack_buffer, size_t stack_buffer_size)
41
41
  {
42
42
  fb->initial_length = (initial_length > 0) ? initial_length : FBUFFER_INITIAL_LENGTH_DEFAULT;
43
43
  if (stack_buffer) {
@@ -50,7 +50,7 @@ static void fbuffer_stack_init(FBuffer *fb, unsigned long initial_length, char *
50
50
  #endif
51
51
  }
52
52
 
53
- static inline void fbuffer_consumed(FBuffer *fb, unsigned long consumed)
53
+ static inline void fbuffer_consumed(FBuffer *fb, size_t consumed)
54
54
  {
55
55
  #if JSON_DEBUG
56
56
  if (consumed > fb->requested) {
@@ -79,7 +79,7 @@ static void fbuffer_flush(FBuffer *fb)
79
79
  fbuffer_clear(fb);
80
80
  }
81
81
 
82
- static void fbuffer_realloc(FBuffer *fb, unsigned long required)
82
+ static void fbuffer_realloc(FBuffer *fb, size_t required)
83
83
  {
84
84
  if (required > fb->capa) {
85
85
  if (fb->type == FBUFFER_STACK_ALLOCATED) {
@@ -94,7 +94,7 @@ static void fbuffer_realloc(FBuffer *fb, unsigned long required)
94
94
  }
95
95
  }
96
96
 
97
- static void fbuffer_do_inc_capa(FBuffer *fb, unsigned long requested)
97
+ static void fbuffer_do_inc_capa(FBuffer *fb, size_t requested)
98
98
  {
99
99
  if (RB_UNLIKELY(fb->io)) {
100
100
  if (fb->capa < FBUFFER_IO_BUFFER_SIZE) {
@@ -108,7 +108,7 @@ static void fbuffer_do_inc_capa(FBuffer *fb, unsigned long requested)
108
108
  }
109
109
  }
110
110
 
111
- unsigned long required;
111
+ size_t required;
112
112
 
113
113
  if (RB_UNLIKELY(!fb->ptr)) {
114
114
  fb->ptr = ALLOC_N(char, fb->initial_length);
@@ -120,7 +120,7 @@ static void fbuffer_do_inc_capa(FBuffer *fb, unsigned long requested)
120
120
  fbuffer_realloc(fb, required);
121
121
  }
122
122
 
123
- static inline void fbuffer_inc_capa(FBuffer *fb, unsigned long requested)
123
+ static inline void fbuffer_inc_capa(FBuffer *fb, size_t requested)
124
124
  {
125
125
  #if JSON_DEBUG
126
126
  fb->requested = requested;
@@ -131,13 +131,13 @@ static inline void fbuffer_inc_capa(FBuffer *fb, unsigned long requested)
131
131
  }
132
132
  }
133
133
 
134
- static inline void fbuffer_append_reserved(FBuffer *fb, const char *newstr, unsigned long len)
134
+ static inline void fbuffer_append_reserved(FBuffer *fb, const char *newstr, size_t len)
135
135
  {
136
136
  MEMCPY(fb->ptr + fb->len, newstr, char, len);
137
137
  fbuffer_consumed(fb, len);
138
138
  }
139
139
 
140
- static inline void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len)
140
+ static inline void fbuffer_append(FBuffer *fb, const char *newstr, size_t len)
141
141
  {
142
142
  if (len > 0) {
143
143
  fbuffer_inc_capa(fb, len);
@@ -162,16 +162,17 @@ static inline void fbuffer_append_reserved_char(FBuffer *fb, char chr)
162
162
  static void fbuffer_append_str(FBuffer *fb, VALUE str)
163
163
  {
164
164
  const char *ptr;
165
- unsigned long len;
165
+ size_t len;
166
166
  RSTRING_GETMEM(str, ptr, len);
167
167
 
168
168
  fbuffer_append(fb, ptr, len);
169
+ RB_GC_GUARD(str);
169
170
  }
170
171
 
171
172
  static void fbuffer_append_str_repeat(FBuffer *fb, VALUE str, size_t repeat)
172
173
  {
173
174
  const char *ptr;
174
- unsigned long len;
175
+ size_t len;
175
176
  RSTRING_GETMEM(str, ptr, len);
176
177
 
177
178
  fbuffer_inc_capa(fb, repeat * len);
@@ -182,6 +183,7 @@ static void fbuffer_append_str_repeat(FBuffer *fb, VALUE str, size_t repeat)
182
183
  fbuffer_append_reserved(fb, ptr, len);
183
184
  repeat--;
184
185
  }
186
+ RB_GC_GUARD(str);
185
187
  }
186
188
 
187
189
  static inline void fbuffer_append_char(FBuffer *fb, char newchr)
@@ -5,6 +5,8 @@ if RUBY_ENGINE == 'truffleruby'
5
5
  File.write('Makefile', dummy_makefile("").join)
6
6
  else
7
7
  append_cflags("-std=c99")
8
+ have_const("RUBY_TYPED_EMBEDDABLE", "ruby.h") # RUBY_VERSION >= 3.3
9
+
8
10
  $defs << "-DJSON_GENERATOR"
9
11
  $defs << "-DJSON_DEBUG" if ENV.fetch("JSON_DEBUG", "0") != "0"
10
12