json 2.15.1 → 2.15.2
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/CHANGES.md +5 -0
- data/ext/json/ext/generator/generator.c +34 -5
- data/lib/json/truffle_ruby/generator.rb +5 -1
- data/lib/json/version.rb +1 -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: b883349b3a8a8c1ccb003e74779a577e3a16e8c3d8541693fb477a78aeac3a68
|
|
4
|
+
data.tar.gz: efb11cf9e69ece0ebb11d33aec23401b0c1ed1d7a39c351f82998ba82cbd47b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f78e23c6bd8b8dcddaaf051d6ae60253fd6c96e108395b475d825d9daf3fba4f754f280ae095f456ee67917dd991c8477caa86038f378f23d49e17744467cb7a
|
|
7
|
+
data.tar.gz: 64946a58a223efb1e333ff15eba3776d44505cfb78ba0102350177b6351f4643107db5f37ddb65c41569b4d58b5147176c8043b182abd152c74c63351be958fd
|
data/CHANGES.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
### Unreleased
|
|
4
4
|
|
|
5
|
+
### 2025-10-25 (2.15.2)
|
|
6
|
+
|
|
7
|
+
* Fix `JSON::Coder` to have one dedicated depth counter per invocation.
|
|
8
|
+
After encountering a circular reference in `JSON::Coder#dump`, any further `#dump` call would raise `JSON::NestingError`.
|
|
9
|
+
|
|
5
10
|
### 2025-10-07 (2.15.1)
|
|
6
11
|
|
|
7
12
|
* Fix incorrect escaping in the JRuby extension when encoding shared strings.
|
|
@@ -1124,7 +1124,7 @@ static inline long increase_depth(struct generate_json_data *data)
|
|
|
1124
1124
|
JSON_Generator_State *state = data->state;
|
|
1125
1125
|
long depth = ++state->depth;
|
|
1126
1126
|
if (RB_UNLIKELY(depth > state->max_nesting && state->max_nesting)) {
|
|
1127
|
-
rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
|
|
1127
|
+
rb_raise(eNestingError, "nesting of %ld is too deep. Did you try to serialize objects with circular references?", --state->depth);
|
|
1128
1128
|
}
|
|
1129
1129
|
return depth;
|
|
1130
1130
|
}
|
|
@@ -1491,10 +1491,39 @@ static VALUE cState_generate(int argc, VALUE *argv, VALUE self)
|
|
|
1491
1491
|
rb_check_arity(argc, 1, 2);
|
|
1492
1492
|
VALUE obj = argv[0];
|
|
1493
1493
|
VALUE io = argc > 1 ? argv[1] : Qnil;
|
|
1494
|
-
|
|
1494
|
+
return cState_partial_generate(self, obj, generate_json, io);
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
static VALUE cState_generate_new(int argc, VALUE *argv, VALUE self)
|
|
1498
|
+
{
|
|
1499
|
+
rb_check_arity(argc, 1, 2);
|
|
1500
|
+
VALUE obj = argv[0];
|
|
1501
|
+
VALUE io = argc > 1 ? argv[1] : Qnil;
|
|
1502
|
+
|
|
1495
1503
|
GET_STATE(self);
|
|
1496
|
-
|
|
1497
|
-
|
|
1504
|
+
|
|
1505
|
+
JSON_Generator_State new_state;
|
|
1506
|
+
MEMCPY(&new_state, state, JSON_Generator_State, 1);
|
|
1507
|
+
|
|
1508
|
+
// FIXME: depth shouldn't be part of JSON_Generator_State, as that prevents it from being used concurrently.
|
|
1509
|
+
new_state.depth = 0;
|
|
1510
|
+
|
|
1511
|
+
char stack_buffer[FBUFFER_STACK_SIZE];
|
|
1512
|
+
FBuffer buffer = {
|
|
1513
|
+
.io = RTEST(io) ? io : Qfalse,
|
|
1514
|
+
};
|
|
1515
|
+
fbuffer_stack_init(&buffer, state->buffer_initial_length, stack_buffer, FBUFFER_STACK_SIZE);
|
|
1516
|
+
|
|
1517
|
+
struct generate_json_data data = {
|
|
1518
|
+
.buffer = &buffer,
|
|
1519
|
+
.vstate = Qfalse,
|
|
1520
|
+
.state = &new_state,
|
|
1521
|
+
.obj = obj,
|
|
1522
|
+
.func = generate_json
|
|
1523
|
+
};
|
|
1524
|
+
rb_rescue(generate_json_try, (VALUE)&data, generate_json_rescue, (VALUE)&data);
|
|
1525
|
+
|
|
1526
|
+
return fbuffer_finalize(&buffer);
|
|
1498
1527
|
}
|
|
1499
1528
|
|
|
1500
1529
|
static VALUE cState_initialize(int argc, VALUE *argv, VALUE self)
|
|
@@ -2072,7 +2101,7 @@ void Init_generator(void)
|
|
|
2072
2101
|
rb_define_method(cState, "buffer_initial_length", cState_buffer_initial_length, 0);
|
|
2073
2102
|
rb_define_method(cState, "buffer_initial_length=", cState_buffer_initial_length_set, 1);
|
|
2074
2103
|
rb_define_method(cState, "generate", cState_generate, -1);
|
|
2075
|
-
|
|
2104
|
+
rb_define_method(cState, "generate_new", cState_generate_new, -1); // :nodoc:
|
|
2076
2105
|
|
|
2077
2106
|
rb_define_private_method(cState, "allow_duplicate_key?", cState_allow_duplicate_key_p, 0);
|
|
2078
2107
|
|
|
@@ -212,7 +212,7 @@ module JSON
|
|
|
212
212
|
return if @max_nesting.zero?
|
|
213
213
|
current_nesting = depth + 1
|
|
214
214
|
current_nesting > @max_nesting and
|
|
215
|
-
raise NestingError, "nesting of #{current_nesting} is too deep"
|
|
215
|
+
raise NestingError, "nesting of #{current_nesting} is too deep. Did you try to serialize objects with circular references?"
|
|
216
216
|
end
|
|
217
217
|
|
|
218
218
|
# Returns true, if circular data structures are checked,
|
|
@@ -347,6 +347,10 @@ module JSON
|
|
|
347
347
|
dup.generate(obj, anIO)
|
|
348
348
|
end
|
|
349
349
|
|
|
350
|
+
private def initialize_copy(_orig)
|
|
351
|
+
@depth = 0
|
|
352
|
+
end
|
|
353
|
+
|
|
350
354
|
# Handles @allow_nan, @buffer_initial_length, other ivars must be the default value (see above)
|
|
351
355
|
private def generate_json(obj, buf)
|
|
352
356
|
case obj
|
data/lib/json/version.rb
CHANGED