oj 2.5.3 → 2.5.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of oj might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +2 -10
- data/ext/oj/oj.c +6 -0
- data/ext/oj/parse.c +23 -0
- data/lib/oj/version.rb +1 -1
- data/test/tests.rb +40 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5ed2da87bfa647cc35c9f601be6ad196d55d383
|
4
|
+
data.tar.gz: 10861e340f51bb1179829e04187115bf4c147370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96b24f234c6f96ea1744d5696dce1544e9be1c8c99d0c25343727cb1302c0097e5cd2425a6a04335f4d662862c557d6e02daff06568e2b0b03c630f6fd8f9787
|
7
|
+
data.tar.gz: f87d369229b94e0ebaec6c2a8fffad056f1a41de63c108eacd4919166f743a74cb914622d2ac702bfe80511a029832c8247991ed896fdb61342341c776f12239
|
data/README.md
CHANGED
@@ -20,17 +20,9 @@ Follow [@peterohler on Twitter](http://twitter.com/#!/peterohler) for announceme
|
|
20
20
|
|
21
21
|
[![Build Status](https://secure.travis-ci.org/ohler55/oj.png?branch=master)](http://travis-ci.org/ohler55/oj)
|
22
22
|
|
23
|
-
### Current Release 2.5.
|
23
|
+
### Current Release 2.5.4
|
24
24
|
|
25
|
-
-
|
26
|
-
|
27
|
-
### Current Release 2.5.2
|
28
|
-
|
29
|
-
- Fixed indent problem with StringWriter so it now indents properly
|
30
|
-
|
31
|
-
### Current Release 2.5.1
|
32
|
-
|
33
|
-
- Added push_json() to the StringWriter and StreamWriter to allow raw JSON to be added to a JSON document being constructed.
|
25
|
+
- Fixed bug where unterminated JSON did not raise an exception.
|
34
26
|
|
35
27
|
[Older release notes](http://www.ohler.com/dev/oj_misc/release_notes.html).
|
36
28
|
|
data/ext/oj/oj.c
CHANGED
@@ -1781,6 +1781,12 @@ void Init_oj() {
|
|
1781
1781
|
oj_utc_offset_id = rb_intern("utc_offset");
|
1782
1782
|
oj_write_id = rb_intern("write");
|
1783
1783
|
|
1784
|
+
rb_require("oj/bag");
|
1785
|
+
rb_require("oj/error");
|
1786
|
+
rb_require("oj/mimic");
|
1787
|
+
rb_require("oj/saj");
|
1788
|
+
rb_require("oj/schandler");
|
1789
|
+
|
1784
1790
|
oj_bag_class = rb_const_get_at(Oj, rb_intern("Bag"));
|
1785
1791
|
oj_bigdecimal_class = rb_const_get(rb_cObject, rb_intern("BigDecimal"));
|
1786
1792
|
oj_date_class = rb_const_get(rb_cObject, rb_intern("Date"));
|
data/ext/oj/parse.c
CHANGED
@@ -799,6 +799,29 @@ oj_pi_parse(int argc, VALUE *argv, ParseInfo pi, char *json, size_t len) {
|
|
799
799
|
if (No == pi->options.allow_gc) {
|
800
800
|
rb_gc_enable();
|
801
801
|
}
|
802
|
+
{
|
803
|
+
// If the stack is not empty then the JSON terminated early.
|
804
|
+
Val v;
|
805
|
+
|
806
|
+
if (0 != (v = stack_peek(&pi->stack))) {
|
807
|
+
switch (v->next) {
|
808
|
+
case NEXT_ARRAY_NEW:
|
809
|
+
case NEXT_ARRAY_ELEMENT:
|
810
|
+
case NEXT_ARRAY_COMMA:
|
811
|
+
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "Array not terminated");
|
812
|
+
break;
|
813
|
+
case NEXT_HASH_NEW:
|
814
|
+
case NEXT_HASH_KEY:
|
815
|
+
case NEXT_HASH_COLON:
|
816
|
+
case NEXT_HASH_VALUE:
|
817
|
+
case NEXT_HASH_COMMA:
|
818
|
+
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "Hash/Object not terminated");
|
819
|
+
break;
|
820
|
+
default:
|
821
|
+
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "not terminated");
|
822
|
+
}
|
823
|
+
}
|
824
|
+
}
|
802
825
|
// proceed with cleanup
|
803
826
|
if (0 != pi->circ_array) {
|
804
827
|
oj_circ_array_free(pi->circ_array);
|
data/lib/oj/version.rb
CHANGED
data/test/tests.rb
CHANGED
@@ -253,6 +253,15 @@ class Juice < ::Test::Unit::TestCase
|
|
253
253
|
dump_and_load([[nil]], false)
|
254
254
|
dump_and_load([[nil], 58], false)
|
255
255
|
end
|
256
|
+
def test_array_not_closed
|
257
|
+
begin
|
258
|
+
Oj.load('[')
|
259
|
+
rescue Exception => e
|
260
|
+
assert(true)
|
261
|
+
return
|
262
|
+
end
|
263
|
+
assert(false, "*** expected an exception")
|
264
|
+
end
|
256
265
|
|
257
266
|
# rails encoding tests
|
258
267
|
def test_does_not_escape_entities_by_default
|
@@ -314,10 +323,11 @@ class Juice < ::Test::Unit::TestCase
|
|
314
323
|
t = Time.local(2012, 1, 5, 23, 58, 7)
|
315
324
|
begin
|
316
325
|
Oj.dump(t, :mode => :strict)
|
317
|
-
assert(false)
|
318
326
|
rescue Exception
|
319
327
|
assert(true)
|
328
|
+
return
|
320
329
|
end
|
330
|
+
assert(false, "*** expected an exception")
|
321
331
|
end
|
322
332
|
def test_time_null
|
323
333
|
t = Time.local(2012, 1, 5, 23, 58, 7)
|
@@ -459,10 +469,11 @@ class Juice < ::Test::Unit::TestCase
|
|
459
469
|
def test_class_strict
|
460
470
|
begin
|
461
471
|
Oj.dump(Juice, :mode => :strict)
|
462
|
-
assert(false)
|
463
472
|
rescue Exception
|
464
473
|
assert(true)
|
474
|
+
return
|
465
475
|
end
|
476
|
+
assert(false, "*** expected an exception")
|
466
477
|
end
|
467
478
|
def test_class_null
|
468
479
|
json = Oj.dump(Juice, :mode => :null)
|
@@ -487,18 +498,20 @@ class Juice < ::Test::Unit::TestCase
|
|
487
498
|
def test_non_str_hash_strict
|
488
499
|
begin
|
489
500
|
Oj.dump({ 1 => true, 0 => false }, :mode => :strict)
|
490
|
-
assert(false)
|
491
501
|
rescue Exception
|
492
502
|
assert(true)
|
503
|
+
return
|
493
504
|
end
|
505
|
+
assert(false, "*** expected an exception")
|
494
506
|
end
|
495
507
|
def test_non_str_hash_null
|
496
508
|
begin
|
497
509
|
Oj.dump({ 1 => true, 0 => false }, :mode => :null)
|
498
|
-
assert(false)
|
499
510
|
rescue Exception
|
500
511
|
assert(true)
|
512
|
+
return
|
501
513
|
end
|
514
|
+
assert(false, "*** expected an exception")
|
502
515
|
end
|
503
516
|
def test_non_str_hash_compat
|
504
517
|
json = Oj.dump({ 1 => true, 0 => false }, :mode => :compat)
|
@@ -521,16 +534,26 @@ class Juice < ::Test::Unit::TestCase
|
|
521
534
|
h = Oj.load(json)
|
522
535
|
assert_equal({ 1 => true, 'nil' => nil, :sim => 4 }, h)
|
523
536
|
end
|
537
|
+
def test_hash_not_closed
|
538
|
+
begin
|
539
|
+
Oj.load('{')
|
540
|
+
rescue Exception => e
|
541
|
+
assert(true)
|
542
|
+
return
|
543
|
+
end
|
544
|
+
assert(false, "*** expected an exception")
|
545
|
+
end
|
524
546
|
|
525
547
|
# Object with to_json()
|
526
548
|
def test_json_object_strict
|
527
549
|
obj = Jeez.new(true, 58)
|
528
550
|
begin
|
529
551
|
Oj.dump(obj, :mode => :strict)
|
530
|
-
assert(false)
|
531
552
|
rescue Exception
|
532
553
|
assert(true)
|
554
|
+
return
|
533
555
|
end
|
556
|
+
assert(false, "*** expected an exception")
|
534
557
|
end
|
535
558
|
def test_json_object_null
|
536
559
|
obj = Jeez.new(true, 58)
|
@@ -575,10 +598,11 @@ class Juice < ::Test::Unit::TestCase
|
|
575
598
|
obj = Jazz.new(true, 58)
|
576
599
|
begin
|
577
600
|
Oj.dump(obj, :mode => :strict)
|
578
|
-
assert(false)
|
579
601
|
rescue Exception
|
580
602
|
assert(true)
|
603
|
+
return
|
581
604
|
end
|
605
|
+
assert(false, "*** expected an exception")
|
582
606
|
end
|
583
607
|
def test_to_hash_object_null
|
584
608
|
obj = Jazz.new(true, 58)
|
@@ -613,10 +637,11 @@ class Juice < ::Test::Unit::TestCase
|
|
613
637
|
obj = Orange.new(true, 58)
|
614
638
|
begin
|
615
639
|
Oj.dump(obj, :mode => :strict)
|
616
|
-
assert(false)
|
617
640
|
rescue Exception
|
618
641
|
assert(true)
|
642
|
+
return
|
619
643
|
end
|
644
|
+
assert(false, "*** expected an exception")
|
620
645
|
end
|
621
646
|
|
622
647
|
def test_as_json_object_null
|
@@ -662,10 +687,11 @@ class Juice < ::Test::Unit::TestCase
|
|
662
687
|
obj = Jam.new(true, 58)
|
663
688
|
begin
|
664
689
|
Oj.dump(obj, :mode => :strict)
|
665
|
-
assert(false)
|
666
690
|
rescue Exception
|
667
691
|
assert(true)
|
692
|
+
return
|
668
693
|
end
|
694
|
+
assert(false, "*** expected an exception")
|
669
695
|
end
|
670
696
|
def test_object_null
|
671
697
|
obj = Jam.new(true, 58)
|
@@ -723,7 +749,6 @@ class Juice < ::Test::Unit::TestCase
|
|
723
749
|
err = nil
|
724
750
|
begin
|
725
751
|
raise StandardError.new('A Message')
|
726
|
-
assert(false)
|
727
752
|
rescue Exception => e
|
728
753
|
err = e
|
729
754
|
end
|
@@ -747,10 +772,11 @@ class Juice < ::Test::Unit::TestCase
|
|
747
772
|
def test_range_strict
|
748
773
|
begin
|
749
774
|
Oj.dump(1..7, :mode => :strict)
|
750
|
-
assert(false)
|
751
775
|
rescue Exception
|
752
776
|
assert(true)
|
777
|
+
return
|
753
778
|
end
|
779
|
+
assert(false, "*** expected an exception")
|
754
780
|
end
|
755
781
|
def test_range_null
|
756
782
|
json = Oj.dump(1..7, :mode => :null)
|
@@ -862,10 +888,11 @@ class Juice < ::Test::Unit::TestCase
|
|
862
888
|
def test_date_strict
|
863
889
|
begin
|
864
890
|
Oj.dump(Date.new(2012, 6, 19), :mode => :strict)
|
865
|
-
assert(false)
|
866
891
|
rescue Exception
|
867
892
|
assert(true)
|
893
|
+
return
|
868
894
|
end
|
895
|
+
assert(false, "*** expected an exception")
|
869
896
|
end
|
870
897
|
def test_date_null
|
871
898
|
json = Oj.dump(Date.new(2012, 6, 19), :mode => :null)
|
@@ -891,10 +918,11 @@ class Juice < ::Test::Unit::TestCase
|
|
891
918
|
def test_datetime_strict
|
892
919
|
begin
|
893
920
|
Oj.dump(DateTime.new(2012, 6, 19, 20, 19, 27), :mode => :strict)
|
894
|
-
assert(false)
|
895
921
|
rescue Exception
|
896
922
|
assert(true)
|
923
|
+
return
|
897
924
|
end
|
925
|
+
assert(false, "*** expected an exception")
|
898
926
|
end
|
899
927
|
def test_datetime_null
|
900
928
|
json = Oj.dump(DateTime.new(2012, 6, 19, 20, 19, 27), :mode => :null)
|
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: 2.5.
|
4
|
+
version: 2.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'The fastest JSON parser and object serializer. '
|
14
14
|
email: peter@ohler.com
|