oj 3.10.14 → 3.10.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/ext/oj/buf.h +2 -30
  3. data/ext/oj/cache8.h +1 -29
  4. data/ext/oj/circarray.c +4 -8
  5. data/ext/oj/circarray.h +1 -4
  6. data/ext/oj/code.c +3 -6
  7. data/ext/oj/code.h +1 -4
  8. data/ext/oj/compat.c +1 -4
  9. data/ext/oj/custom.c +1 -4
  10. data/ext/oj/dump.c +23 -13
  11. data/ext/oj/dump.h +1 -4
  12. data/ext/oj/dump_compat.c +1 -4
  13. data/ext/oj/dump_leaf.c +2 -5
  14. data/ext/oj/dump_object.c +1 -4
  15. data/ext/oj/dump_strict.c +1 -4
  16. data/ext/oj/encode.h +1 -29
  17. data/ext/oj/err.c +1 -4
  18. data/ext/oj/err.h +1 -29
  19. data/ext/oj/fast.c +14 -42
  20. data/ext/oj/hash.c +4 -32
  21. data/ext/oj/hash.h +1 -29
  22. data/ext/oj/hash_test.c +1 -29
  23. data/ext/oj/mimic_json.c +11 -6
  24. data/ext/oj/object.c +1 -4
  25. data/ext/oj/odd.c +1 -4
  26. data/ext/oj/odd.h +1 -4
  27. data/ext/oj/oj.c +16 -4
  28. data/ext/oj/oj.h +2 -4
  29. data/ext/oj/parse.c +7 -16
  30. data/ext/oj/parse.h +1 -4
  31. data/ext/oj/rails.c +1 -4
  32. data/ext/oj/rails.h +1 -4
  33. data/ext/oj/reader.c +5 -8
  34. data/ext/oj/reader.h +2 -5
  35. data/ext/oj/resolve.c +1 -4
  36. data/ext/oj/resolve.h +1 -4
  37. data/ext/oj/rxclass.c +3 -6
  38. data/ext/oj/rxclass.h +1 -4
  39. data/ext/oj/saj.c +6 -9
  40. data/ext/oj/scp.c +1 -4
  41. data/ext/oj/sparse.c +7 -15
  42. data/ext/oj/stream_writer.c +4 -9
  43. data/ext/oj/strict.c +3 -6
  44. data/ext/oj/string_writer.c +1 -4
  45. data/ext/oj/trace.c +5 -8
  46. data/ext/oj/trace.h +1 -4
  47. data/ext/oj/util.c +1 -1
  48. data/ext/oj/util.h +1 -1
  49. data/ext/oj/val_stack.c +1 -29
  50. data/ext/oj/val_stack.h +1 -29
  51. data/ext/oj/wab.c +1 -4
  52. data/lib/oj/version.rb +1 -1
  53. data/pages/Modes.md +1 -1
  54. data/pages/Options.md +4 -0
  55. data/test/test_compat.rb +14 -1
  56. data/test/test_rails.rb +9 -0
  57. metadata +5 -5
data/ext/oj/wab.c CHANGED
@@ -1,7 +1,4 @@
1
- /* wab.c
2
- * Copyright (c) 2012, Peter Ohler
3
- * All rights reserved.
4
- */
1
+ // Copyright (c) 2012 Peter Ohler. All rights reserved.
5
2
 
6
3
  #include <stdlib.h>
7
4
  #include <stdio.h>
data/lib/oj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.10.14'
4
+ VERSION = '3.10.17'
5
5
  end
data/pages/Modes.md CHANGED
@@ -94,7 +94,7 @@ information.
94
94
  | :array_nl | String | | | | | | x | |
95
95
  | :ascii_only | Boolean | x | x | 2 | 2 | x | x | |
96
96
  | :auto_define | Boolean | | | | | x | x | |
97
- | :bigdecimal_as_decimal | Boolean | | | | 3 | x | x | |
97
+ | :bigdecimal_as_decimal | Boolean | | | x | 3 | x | x | |
98
98
  | :bigdecimal_load | Boolean | | | | | | x | |
99
99
  | :circular | Boolean | x | x | x | x | x | x | |
100
100
  | :class_cache | Boolean | | | | | x | x | |
data/pages/Options.md CHANGED
@@ -66,6 +66,10 @@ Determines how to load decimals.
66
66
 
67
67
  - `:auto` the most precise for the number of digits is used.
68
68
 
69
+ This can also be set with `:decimal_class` when used as a load or
70
+ parse option to match the JSON gem. In that case either `Float`,
71
+ `BigDecimal`, or `nil` can be provided.
72
+
69
73
  ### :circular [Boolean]
70
74
 
71
75
  Detect circular references while dumping. In :compat mode raise a
data/test/test_compat.rb CHANGED
@@ -236,6 +236,12 @@ class CompatJuice < Minitest::Test
236
236
  assert_equal({"a\nb" => true, "c\td" => false}, obj)
237
237
  end
238
238
 
239
+ def test_invalid_escapes_handled
240
+ json = '{"subtext":"\"404er\” \w \k \3 \a"}'
241
+ obj = Oj.compat_load(json)
242
+ assert_equal({"subtext" => "\"404er” w k 3 a"}, obj)
243
+ end
244
+
239
245
  def test_hash_escaping
240
246
  json = Oj.to_json({'<>' => '<>'}, mode: :compat)
241
247
  assert_equal(json, '{"<>":"<>"}')
@@ -271,12 +277,19 @@ class CompatJuice < Minitest::Test
271
277
  # BigDecimal
272
278
  def test_bigdecimal
273
279
  # BigDecimals are dumped as strings and can not be restored to the
274
- # original value.
280
+ # original value without using an undocumented feature of the JSON gem.
275
281
  json = Oj.dump(BigDecimal('3.14159265358979323846'))
276
282
  # 2.4.0 changes the exponent to lowercase
277
283
  assert_equal('"0.314159265358979323846e1"', json.downcase)
278
284
  end
279
285
 
286
+ def test_bigdecimal_load
287
+ big = BigDecimal('3.14159265358979323846')
288
+ # :decimal_class is the undocumented feature.
289
+ json = Oj.load('3.14159265358979323846', mode: :compat, decimal_class: BigDecimal)
290
+ assert_equal(big, json)
291
+ end
292
+
280
293
  def test_infinity
281
294
  assert_raises(Oj::ParseError) { Oj.load('Infinity', :mode => :strict) }
282
295
  x = Oj.load('Infinity', :mode => :compat)
data/test/test_rails.rb CHANGED
@@ -23,4 +23,13 @@ class RailsJuice < Minitest::Test
23
23
  assert_equal('0.123e3', json.downcase)
24
24
  end
25
25
 
26
+ def test_invalid_encoding
27
+ assert_raises(EncodingError) {
28
+ Oj.dump("\"\xf3j", mode: :rails)
29
+ }
30
+ assert_raises(EncodingError) {
31
+ Oj.dump("\xf3j", mode: :rails)
32
+ }
33
+ end
34
+
26
35
  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.10.14
4
+ version: 3.10.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-05 00:00:00.000000000 Z
11
+ date: 2020-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -265,7 +265,7 @@ metadata:
265
265
  homepage_uri: http://www.ohler.com/oj/
266
266
  source_code_uri: https://github.com/ohler55/oj
267
267
  wiki_uri: https://github.com/ohler55/oj/wiki
268
- post_install_message:
268
+ post_install_message:
269
269
  rdoc_options:
270
270
  - "--title"
271
271
  - Oj
@@ -285,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
285
  version: '0'
286
286
  requirements: []
287
287
  rubygems_version: 3.1.2
288
- signing_key:
288
+ signing_key:
289
289
  specification_version: 4
290
290
  summary: A fast JSON parser and serializer.
291
291
  test_files: