json 2.19.4 → 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 +4 -4
- data/CHANGES.md +5 -1
- data/ext/json/ext/generator/generator.c +21 -7
- data/ext/json/ext/parser/parser.c +7 -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: 0bbb85e1521c171ca73ab935cc00899ff3eb7086921a64542a3937fa9589848d
|
|
4
|
+
data.tar.gz: 328853f7f164d91522d6791a51cca5ccb3ae418410752a3fb72189bc14c157d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 326b0621e562eebc66f155cee358ca295dde7584e7f60268a354da3e8a1a02e13bfcd9fef7f9b2f9f2ea196987b07bb9e50578347231f14d9fb0e863ac9445ac
|
|
7
|
+
data.tar.gz: 0e9e2ab4c91b5544ac8440613a0fd63aab2f7b7ce5a39f41e786af736e80ca28de8d3388057134dde05ba53f4f150d24aa1a8cde92dac82abbb4104740409631
|
data/CHANGES.md
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
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
|
+
|
|
5
9
|
### 2026-04-19 (2.19.4)
|
|
6
10
|
|
|
7
|
-
* Fix parsing of out of range floats (very large exponents that lead
|
|
11
|
+
* Fix parsing of out of range floats (very large exponents that lead to either `0.0` or `Inf`).
|
|
8
12
|
|
|
9
13
|
### 2026-03-25 (2.19.3)
|
|
10
14
|
|
|
@@ -819,9 +819,17 @@ static VALUE encode_json_string_rescue(VALUE str, VALUE exception)
|
|
|
819
819
|
return Qundef;
|
|
820
820
|
}
|
|
821
821
|
|
|
822
|
+
static inline int json_str_coderange(VALUE str) {
|
|
823
|
+
int coderange = RB_ENC_CODERANGE(str);
|
|
824
|
+
if (coderange == RUBY_ENC_CODERANGE_UNKNOWN) {
|
|
825
|
+
coderange = rb_enc_str_coderange(str);
|
|
826
|
+
}
|
|
827
|
+
return coderange;
|
|
828
|
+
}
|
|
829
|
+
|
|
822
830
|
static inline bool valid_json_string_p(VALUE str)
|
|
823
831
|
{
|
|
824
|
-
int coderange =
|
|
832
|
+
int coderange = json_str_coderange(str);
|
|
825
833
|
|
|
826
834
|
if (RB_LIKELY(coderange == ENC_CODERANGE_7BIT)) {
|
|
827
835
|
return true;
|
|
@@ -834,12 +842,8 @@ static inline bool valid_json_string_p(VALUE str)
|
|
|
834
842
|
return false;
|
|
835
843
|
}
|
|
836
844
|
|
|
837
|
-
static
|
|
845
|
+
NOINLINE(static) VALUE convert_invalid_encoding(struct generate_json_data *data, VALUE str, bool as_json_called, bool is_key)
|
|
838
846
|
{
|
|
839
|
-
if (RB_LIKELY(valid_json_string_p(str))) {
|
|
840
|
-
return str;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
847
|
if (!as_json_called && data->state->strict && RTEST(data->state->as_json)) {
|
|
844
848
|
VALUE coerced_str = json_call_as_json(data->state, str, Qfalse);
|
|
845
849
|
if (coerced_str != str) {
|
|
@@ -875,6 +879,16 @@ static inline VALUE ensure_valid_encoding(struct generate_json_data *data, VALUE
|
|
|
875
879
|
return rb_rescue(encode_json_string_try, str, encode_json_string_rescue, str);
|
|
876
880
|
}
|
|
877
881
|
|
|
882
|
+
ALWAYS_INLINE(static) VALUE ensure_valid_encoding(struct generate_json_data *data, VALUE str, bool as_json_called, bool is_key)
|
|
883
|
+
{
|
|
884
|
+
if (RB_LIKELY(valid_json_string_p(str))) {
|
|
885
|
+
return str;
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
return convert_invalid_encoding(data, str, as_json_called, is_key);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
|
|
878
892
|
static void raw_generate_json_string(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
|
|
879
893
|
{
|
|
880
894
|
fbuffer_append_char(buffer, '"');
|
|
@@ -893,7 +907,7 @@ static void raw_generate_json_string(FBuffer *buffer, struct generate_json_data
|
|
|
893
907
|
search.chunk_end = NULL;
|
|
894
908
|
#endif /* HAVE_SIMD */
|
|
895
909
|
|
|
896
|
-
switch (
|
|
910
|
+
switch (json_str_coderange(obj)) {
|
|
897
911
|
case ENC_CODERANGE_7BIT:
|
|
898
912
|
case ENC_CODERANGE_VALID:
|
|
899
913
|
if (RB_UNLIKELY(data->state->ascii_only)) {
|
|
@@ -364,6 +364,7 @@ typedef struct JSON_ParserStateStruct {
|
|
|
364
364
|
rvalue_cache name_cache;
|
|
365
365
|
int in_array;
|
|
366
366
|
int current_nesting;
|
|
367
|
+
unsigned int emitted_deprecations;
|
|
367
368
|
} JSON_ParserState;
|
|
368
369
|
|
|
369
370
|
static inline size_t rest(JSON_ParserState *state) {
|
|
@@ -945,7 +946,12 @@ static inline VALUE json_decode_object(JSON_ParserState *state, JSON_ParserConfi
|
|
|
945
946
|
case JSON_IGNORE:
|
|
946
947
|
break;
|
|
947
948
|
case JSON_DEPRECATED:
|
|
948
|
-
|
|
949
|
+
// Only emit the first few deprecations to avoid spamming.
|
|
950
|
+
if (state->emitted_deprecations < 5) {
|
|
951
|
+
emit_duplicate_key_warning(state, json_find_duplicated_key(count, pairs));
|
|
952
|
+
state->emitted_deprecations++;
|
|
953
|
+
}
|
|
954
|
+
|
|
949
955
|
break;
|
|
950
956
|
case JSON_RAISE:
|
|
951
957
|
raise_duplicate_key_error(state, json_find_duplicated_key(count, pairs));
|
data/lib/json/version.rb
CHANGED