oj 3.7.8 → 3.7.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/oj/mimic_json.c +1 -1
- data/ext/oj/parse.c +23 -8
- data/ext/oj/rails.c +1 -1
- data/lib/oj/version.rb +1 -1
- data/test/test_various.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73661a33c10dd2efe5e942e8eb7b584a065803d5ab0516c7362210e0b7f6ce29
|
4
|
+
data.tar.gz: 6091f05664c4f290858f86efb405b1e17732b1eecb7ccb1829c1d2944a6a5a8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a54eb58d01658e36c63f29128c47e026ce05687261465793f4328146807d5b32a4af6c8286f3f4dbe176e1bd1613214ea6e260051ee0477abd1e7ab27173fa7
|
7
|
+
data.tar.gz: b90c7c8e526636640b5b346fad295fe4b0a7c97671e7acafd5e55ee71b9e6f0727c0dae9eeec58dc1b8729040f91ea14717e6cadb13bce65bf7f428bbfe6cb6e
|
data/ext/oj/mimic_json.c
CHANGED
@@ -631,7 +631,7 @@ mimic_set_create_id(VALUE self, VALUE id) {
|
|
631
631
|
Check_Type(id, T_STRING);
|
632
632
|
|
633
633
|
if (NULL != oj_default_options.create_id) {
|
634
|
-
if (oj_json_class != oj_default_options.create_id
|
634
|
+
if (oj_json_class != oj_default_options.create_id) {
|
635
635
|
xfree((char*)oj_default_options.create_id);
|
636
636
|
}
|
637
637
|
oj_default_options.create_id = NULL;
|
data/ext/oj/parse.c
CHANGED
@@ -418,7 +418,7 @@ read_num(ParseInfo pi) {
|
|
418
418
|
} else {
|
419
419
|
int dec_cnt = 0;
|
420
420
|
bool zero1 = false;
|
421
|
-
|
421
|
+
|
422
422
|
for (; '0' <= *pi->cur && *pi->cur <= '9'; pi->cur++) {
|
423
423
|
if (0 == ni.i && '0' == *pi->cur) {
|
424
424
|
zero1 = true;
|
@@ -607,7 +607,7 @@ oj_parse2(ParseInfo pi) {
|
|
607
607
|
while (1) {
|
608
608
|
if (0 < pi->max_depth && pi->max_depth <= pi->stack.tail - pi->stack.head - 1) {
|
609
609
|
VALUE err_clas = oj_get_json_err_class("NestingError");
|
610
|
-
|
610
|
+
|
611
611
|
oj_set_error_at(pi, err_clas, __FILE__, __LINE__, "Too deeply nested.");
|
612
612
|
pi->err_class = err_clas;
|
613
613
|
return;
|
@@ -729,6 +729,17 @@ oj_parse2(ParseInfo pi) {
|
|
729
729
|
}
|
730
730
|
}
|
731
731
|
|
732
|
+
static VALUE
|
733
|
+
rescue_big_decimal(VALUE str) {
|
734
|
+
rb_raise(oj_parse_error_class, "Invalid value for BigDecimal()");
|
735
|
+
return Qnil;
|
736
|
+
}
|
737
|
+
|
738
|
+
static VALUE
|
739
|
+
parse_big_decimal(VALUE str) {
|
740
|
+
return rb_funcall(rb_cObject, oj_bigdecimal_id, 1, str);
|
741
|
+
}
|
742
|
+
|
732
743
|
VALUE
|
733
744
|
oj_num_as_value(NumInfo ni) {
|
734
745
|
volatile VALUE rnum = Qnil;
|
@@ -766,7 +777,9 @@ oj_num_as_value(NumInfo ni) {
|
|
766
777
|
}
|
767
778
|
} else { // decimal
|
768
779
|
if (ni->big) {
|
769
|
-
|
780
|
+
volatile VALUE bd = rb_str_new(ni->str, ni->len);
|
781
|
+
|
782
|
+
rnum = rb_rescue2(parse_big_decimal, bd, rescue_big_decimal, bd, rb_eException, 0);
|
770
783
|
if (ni->no_big) {
|
771
784
|
rnum = rb_funcall(rnum, rb_intern("to_f"), 0);
|
772
785
|
}
|
@@ -779,7 +792,9 @@ oj_num_as_value(NumInfo ni) {
|
|
779
792
|
// 15 digits. This attempts to fix those few cases where this
|
780
793
|
// occurs.
|
781
794
|
if ((long double)INT64_MAX > d && (int64_t)d != (ni->i * ni->div + ni->num)) {
|
782
|
-
|
795
|
+
volatile VALUE bd = rb_str_new(ni->str, ni->len);
|
796
|
+
|
797
|
+
rnum = rb_rescue2(parse_big_decimal, bd, rescue_big_decimal, bd, rb_eException, 0);
|
783
798
|
if (ni->no_big) {
|
784
799
|
rnum = rb_funcall(rnum, rb_intern("to_f"), 0);
|
785
800
|
}
|
@@ -833,7 +848,7 @@ oj_set_error_at(ParseInfo pi, VALUE err_clas, const char* file, int line, const
|
|
833
848
|
break;
|
834
849
|
}
|
835
850
|
p += snprintf(p, end - p, "[%ld]", RARRAY_LEN(vp->val));
|
836
|
-
}
|
851
|
+
}
|
837
852
|
}
|
838
853
|
}
|
839
854
|
*p++ = ')';
|
@@ -976,12 +991,12 @@ oj_pi_parse(int argc, VALUE *argv, ParseInfo pi, char *json, size_t len, int yie
|
|
976
991
|
if (0 != line) {
|
977
992
|
VALUE ec = rb_obj_class(rb_errinfo());
|
978
993
|
|
979
|
-
if (rb_eIOError != ec) {
|
980
|
-
goto CLEANUP;
|
981
|
-
}
|
982
994
|
if (rb_eArgError != ec && 0 != ec) {
|
983
995
|
err_class = ec;
|
984
996
|
}
|
997
|
+
if (rb_eIOError != ec) {
|
998
|
+
goto CLEANUP;
|
999
|
+
}
|
985
1000
|
}
|
986
1001
|
if (NULL != (v = stack_peek(&pi->stack))) {
|
987
1002
|
switch (v->next) {
|
data/ext/oj/rails.c
CHANGED
data/lib/oj/version.rb
CHANGED
data/test/test_various.rb
CHANGED
@@ -687,8 +687,8 @@ class Juice < Minitest::Test
|
|
687
687
|
|
688
688
|
def test_bad_bignum
|
689
689
|
if '2.4.0' < RUBY_VERSION
|
690
|
-
assert_raises
|
691
|
-
Oj.load(%|{ "big": -e123456789 }
|
690
|
+
assert_raises Oj::ParseError do
|
691
|
+
Oj.load(%|{ "big": -e123456789 }|, mode: :strict)
|
692
692
|
end
|
693
693
|
end
|
694
694
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|