oj 3.13.13 → 3.13.16

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_file.rb CHANGED
@@ -212,6 +212,24 @@ class FileJuice < Minitest::Test
212
212
  dump_and_load(DateTime.new(2012, 6, 19), false)
213
213
  end
214
214
 
215
+ def test_load_unicode_path
216
+ json =<<~JSON
217
+ {
218
+ "x":true,
219
+ "y":58,
220
+ "z": [1,2,3]
221
+ }
222
+ JSON
223
+
224
+ Tempfile.create('file_test_conceição1.json') do |f|
225
+ f.write(json)
226
+ f.close
227
+
228
+ objects = Oj.load_file(f.path)
229
+ assert_equal(Oj.load(json), objects)
230
+ end
231
+ end
232
+
215
233
  def dump_and_load(obj, trace=false)
216
234
  filename = File.join(File.dirname(__FILE__), 'file_test.json')
217
235
  File.open(filename, "w") { |f|
@@ -5,7 +5,7 @@ $: << File.dirname(__FILE__)
5
5
 
6
6
  require 'helper'
7
7
 
8
- $json = %{{
8
+ $json = %|{
9
9
  "array": [
10
10
  {
11
11
  "num" : 3,
@@ -18,7 +18,7 @@ $json = %{{
18
18
  }
19
19
  ],
20
20
  "boolean" : true
21
- }}
21
+ }|
22
22
 
23
23
  class AllSaj < Oj::Saj
24
24
  attr_accessor :calls
@@ -53,6 +53,35 @@ class AllSaj < Oj::Saj
53
53
 
54
54
  end # AllSaj
55
55
 
56
+ class LocSaj
57
+ attr_accessor :calls
58
+
59
+ def initialize()
60
+ @calls = []
61
+ end
62
+
63
+ def hash_start(key, line, column)
64
+ @calls << [:hash_start, key, line, column]
65
+ end
66
+
67
+ def hash_end(key, line, column)
68
+ @calls << [:hash_end, key, line, column]
69
+ end
70
+
71
+ def array_start(key, line, column)
72
+ @calls << [:array_start, key, line, column]
73
+ end
74
+
75
+ def array_end(key, line, column)
76
+ @calls << [:array_end, key, line, column]
77
+ end
78
+
79
+ def add_value(value, key, line, column)
80
+ @calls << [:add_value, value, key, line, column]
81
+ end
82
+
83
+ end # LocSaj
84
+
56
85
  class SajTest < Minitest::Test
57
86
 
58
87
  def test_nil
@@ -242,4 +271,28 @@ class SajTest < Minitest::Test
242
271
  ], handler.calls)
243
272
  end
244
273
 
274
+ def test_loc
275
+ handler = LocSaj.new()
276
+ Oj::Parser.saj.handler = handler
277
+ Oj::Parser.saj.parse($json)
278
+ assert_equal([[:hash_start, nil, 1, 1],
279
+ [:array_start, 'array', 2, 12],
280
+ [:hash_start, nil, 3, 5],
281
+ [:add_value, 3, 'num', 4, 18],
282
+ [:add_value, 'message', 'string', 5, 25],
283
+ [:hash_start, 'hash', 6, 17],
284
+ [:hash_start, 'h2', 7, 17],
285
+ [:array_start, 'a', 8, 17],
286
+ [:add_value, 1, nil, 8, 20],
287
+ [:add_value, 2, nil, 8, 23],
288
+ [:add_value, 3, nil, 8, 26],
289
+ [:array_end, 'a', 8, 27],
290
+ [:hash_end, 'h2', 9, 9],
291
+ [:hash_end, 'hash', 10, 7],
292
+ [:hash_end, nil, 11, 5],
293
+ [:array_end, 'array', 12, 3],
294
+ [:add_value, true, 'boolean', 13, 18],
295
+ [:hash_end, nil, 14, 1]], handler.calls)
296
+ end
297
+
245
298
  end
data/test/test_various.rb CHANGED
@@ -345,6 +345,12 @@ class Juice < Minitest::Test
345
345
  out = Oj.dump hash
346
346
  assert_equal(%{{"key":"I \\u003c3 this"}}, out)
347
347
  end
348
+ def test_escapes_slashes_by_default_when_configured_to_do_so
349
+ hash = {'key' => "I <3 this </script>"}
350
+ Oj.default_options = {:escape_mode => :slash}
351
+ out = Oj.dump hash
352
+ assert_equal(%{{"key":"I <3 this <\\/script>"}}, out)
353
+ end
348
354
  def test_escapes_entities_when_asked_to
349
355
  hash = {'key' => "I <3 this"}
350
356
  out = Oj.dump(hash, :escape_mode => :xss_safe)
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.13.13
4
+ version: 3.13.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -58,20 +58,6 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3.0'
61
- - !ruby/object:Gem::Dependency
62
- name: wwtd
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
61
  description: The fastest JSON parser and object serializer.
76
62
  email: peter@ohler.com
77
63
  executables: []
@@ -200,6 +186,11 @@ files:
200
186
  - test/activesupport6/test_common.rb
201
187
  - test/activesupport6/test_helper.rb
202
188
  - test/activesupport6/time_zone_test_helpers.rb
189
+ - test/activesupport7/abstract_unit.rb
190
+ - test/activesupport7/decoding_test.rb
191
+ - test/activesupport7/encoding_test.rb
192
+ - test/activesupport7/encoding_test_cases.rb
193
+ - test/activesupport7/time_zone_test_helpers.rb
203
194
  - test/bar.rb
204
195
  - test/baz.rb
205
196
  - test/bug.rb
@@ -312,103 +303,4 @@ rubygems_version: 3.3.3
312
303
  signing_key:
313
304
  specification_version: 4
314
305
  summary: A fast JSON parser and serializer.
315
- test_files:
316
- - test/_test_active.rb
317
- - test/_test_active_mimic.rb
318
- - test/_test_mimic_rails.rb
319
- - test/activerecord/result_test.rb
320
- - test/activesupport4/decoding_test.rb
321
- - test/activesupport4/encoding_test.rb
322
- - test/activesupport4/test_helper.rb
323
- - test/activesupport5/abstract_unit.rb
324
- - test/activesupport5/decoding_test.rb
325
- - test/activesupport5/encoding_test.rb
326
- - test/activesupport5/encoding_test_cases.rb
327
- - test/activesupport5/test_helper.rb
328
- - test/activesupport5/time_zone_test_helpers.rb
329
- - test/activesupport6/abstract_unit.rb
330
- - test/activesupport6/decoding_test.rb
331
- - test/activesupport6/encoding_test.rb
332
- - test/activesupport6/encoding_test_cases.rb
333
- - test/activesupport6/test_common.rb
334
- - test/activesupport6/test_helper.rb
335
- - test/activesupport6/time_zone_test_helpers.rb
336
- - test/bar.rb
337
- - test/baz.rb
338
- - test/bug.rb
339
- - test/files.rb
340
- - test/foo.rb
341
- - test/helper.rb
342
- - test/isolated/shared.rb
343
- - test/isolated/test_mimic_after.rb
344
- - test/isolated/test_mimic_alone.rb
345
- - test/isolated/test_mimic_as_json.rb
346
- - test/isolated/test_mimic_before.rb
347
- - test/isolated/test_mimic_define.rb
348
- - test/isolated/test_mimic_rails_after.rb
349
- - test/isolated/test_mimic_rails_before.rb
350
- - test/isolated/test_mimic_redefine.rb
351
- - test/json_gem/json_addition_test.rb
352
- - test/json_gem/json_common_interface_test.rb
353
- - test/json_gem/json_encoding_test.rb
354
- - test/json_gem/json_ext_parser_test.rb
355
- - test/json_gem/json_fixtures_test.rb
356
- - test/json_gem/json_generator_test.rb
357
- - test/json_gem/json_generic_object_test.rb
358
- - test/json_gem/json_parser_test.rb
359
- - test/json_gem/json_string_matching_test.rb
360
- - test/json_gem/test_helper.rb
361
- - test/mem.rb
362
- - test/perf.rb
363
- - test/perf_compat.rb
364
- - test/perf_dump.rb
365
- - test/perf_fast.rb
366
- - test/perf_file.rb
367
- - test/perf_object.rb
368
- - test/perf_once.rb
369
- - test/perf_parser.rb
370
- - test/perf_saj.rb
371
- - test/perf_scp.rb
372
- - test/perf_simple.rb
373
- - test/perf_strict.rb
374
- - test/perf_wab.rb
375
- - test/prec.rb
376
- - test/sample/change.rb
377
- - test/sample/dir.rb
378
- - test/sample/doc.rb
379
- - test/sample/file.rb
380
- - test/sample/group.rb
381
- - test/sample/hasprops.rb
382
- - test/sample/layer.rb
383
- - test/sample/line.rb
384
- - test/sample/oval.rb
385
- - test/sample/rect.rb
386
- - test/sample/shape.rb
387
- - test/sample/text.rb
388
- - test/sample.rb
389
- - test/sample_json.rb
390
- - test/test_compat.rb
391
- - test/test_custom.rb
392
- - test/test_debian.rb
393
- - test/test_fast.rb
394
- - test/test_file.rb
395
- - test/test_gc.rb
396
- - test/test_generate.rb
397
- - test/test_hash.rb
398
- - test/test_integer_range.rb
399
- - test/test_null.rb
400
- - test/test_object.rb
401
- - test/test_parser.rb
402
- - test/test_parser_saj.rb
403
- - test/test_parser_usual.rb
404
- - test/test_rails.rb
405
- - test/test_saj.rb
406
- - test/test_scp.rb
407
- - test/test_strict.rb
408
- - test/test_various.rb
409
- - test/test_wab.rb
410
- - test/test_writer.rb
411
- - test/tests.rb
412
- - test/tests_mimic.rb
413
- - test/tests_mimic_addition.rb
414
- - test/zoo.rb
306
+ test_files: []