json_pure 1.5.5 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/CHANGES +3 -7
  2. data/Gemfile +0 -4
  3. data/Rakefile +0 -7
  4. data/VERSION +1 -1
  5. data/ext/json/ext/parser/parser.c +18 -18
  6. data/ext/json/ext/parser/parser.rl +1 -4
  7. data/install.rb +1 -8
  8. data/java/src/json/ext/Parser.java +85 -81
  9. data/java/src/json/ext/Parser.rl +1 -1
  10. data/json.gemspec +5 -6
  11. data/json_pure.gemspec +4 -8
  12. data/lib/json/add/core.rb +9 -244
  13. data/lib/json/add/date.rb +34 -0
  14. data/lib/json/add/date_time.rb +50 -0
  15. data/lib/json/add/exception.rb +31 -0
  16. data/lib/json/add/range.rb +29 -0
  17. data/lib/json/add/regexp.rb +30 -0
  18. data/lib/json/add/struct.rb +30 -0
  19. data/lib/json/add/symbol.rb +25 -0
  20. data/lib/json/add/time.rb +35 -0
  21. data/lib/json/common.rb +5 -12
  22. data/lib/json/pure/parser.rb +4 -4
  23. data/lib/json/version.rb +1 -1
  24. data/tests/test_json.rb +2 -22
  25. data/tests/test_json_addition.rb +21 -29
  26. data/tests/test_json_string_matching.rb +6 -5
  27. data/tools/server.rb +1 -0
  28. metadata +125 -174
  29. data/0001-Security-fix-create_additons-JSON-GenericObject.patch +0 -448
  30. data/0001-Security-fix-create_additons-problem-1.5.5.patch +0 -630
  31. data/0001-Security-fix-for-create_additions-problem-1.6.8.patch +0 -685
  32. data/Gemfile.lock +0 -60
  33. data/bin/edit_json.rb +0 -9
  34. data/bin/prettify_json.rb +0 -48
  35. data/lib/json/Array.xpm +0 -21
  36. data/lib/json/FalseClass.xpm +0 -21
  37. data/lib/json/Hash.xpm +0 -21
  38. data/lib/json/Key.xpm +0 -73
  39. data/lib/json/NilClass.xpm +0 -21
  40. data/lib/json/Numeric.xpm +0 -28
  41. data/lib/json/String.xpm +0 -96
  42. data/lib/json/TrueClass.xpm +0 -21
  43. data/lib/json/editor.rb +0 -1369
  44. data/lib/json/json.xpm +0 -1499
@@ -1,448 +0,0 @@
1
- From a26f7e96b52efe0be508e223cd31f97ed04099ea Mon Sep 17 00:00:00 2001
2
- From: Florian Frank <flori@ping.de>
3
- Date: Mon, 4 Feb 2013 23:28:30 +0100
4
- Subject: [PATCH] Security fix create_additons/JSON::GenericObject
5
-
6
- ---
7
- CHANGES | 8 ++++++
8
- Gemfile | 1 +
9
- ext/json/ext/parser/parser.c | 2 +-
10
- ext/json/ext/parser/parser.rl | 2 +-
11
- java/src/json/ext/Parser.java | 2 +-
12
- java/src/json/ext/Parser.rl | 2 +-
13
- json.gemspec | 2 +-
14
- json_pure.gemspec | 2 +-
15
- lib/json/common.rb | 21 +++++++++-----
16
- lib/json/generic_object.rb | 7 +++++
17
- lib/json/pure/parser.rb | 8 +++---
18
- tests/test_json.rb | 10 +++++--
19
- tests/test_json_addition.rb | 56 ++++++++++++++++++++++----------------
20
- tests/test_json_generic_object.rb | 30 ++++++++++++++------
21
- tests/test_json_string_matching.rb | 7 ++---
22
- 15 files changed, 105 insertions(+), 55 deletions(-)
23
-
24
- diff --git a/CHANGES b/CHANGES
25
- index a8c0b35..e3d12a7 100644
26
- --- a/CHANGES
27
- +++ b/CHANGES
28
- @@ -1,4 +1,12 @@
29
- 2013-02-04 (1.7.7)
30
- + * Security fix for JSON create_additions default value and
31
- + JSON::GenericObject. It should not be possible to create additions unless
32
- + explicitely requested by setting the create_additions argument to true or
33
- + using the JSON.load/dump interface. If JSON::GenericObject is supposed to
34
- + be automatically deserialised, this has to be explicitely enabled by
35
- + setting
36
- + JSON::GenericObject.json_createble = true
37
- + as well.
38
- * Remove useless assert in fbuffer implementation.
39
- * Apply patch attached to https://github.com/flori/json/issues#issue/155
40
- provided by John Shahid <jvshahid@gmail.com>, Thx!
41
- diff --git a/Gemfile b/Gemfile
42
- index 98d7837..e405da2 100644
43
- --- a/Gemfile
44
- +++ b/Gemfile
45
- @@ -8,3 +8,4 @@ gemspec :name => 'json-java'
46
-
47
- gem 'utils'
48
- gem 'test-unit'
49
- +gem 'debugger', :platform => :mri_19
50
- diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
51
- index 8442d21..df89f2c 100644
52
- --- a/ext/json/ext/parser/parser.c
53
- +++ b/ext/json/ext/parser/parser.c
54
- @@ -1680,7 +1680,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
55
- if (option_given_p(opts, tmp)) {
56
- json->create_additions = RTEST(rb_hash_aref(opts, tmp));
57
- } else {
58
- - json->create_additions = 1;
59
- + json->create_additions = 0;
60
- }
61
- tmp = ID2SYM(i_create_id);
62
- if (option_given_p(opts, tmp)) {
63
- diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl
64
- index 6138a6f..ab8d318 100644
65
- --- a/ext/json/ext/parser/parser.rl
66
- +++ b/ext/json/ext/parser/parser.rl
67
- @@ -664,7 +664,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
68
- if (option_given_p(opts, tmp)) {
69
- json->create_additions = RTEST(rb_hash_aref(opts, tmp));
70
- } else {
71
- - json->create_additions = 1;
72
- + json->create_additions = 0;
73
- }
74
- tmp = ID2SYM(i_create_id);
75
- if (option_given_p(opts, tmp)) {
76
- diff --git a/java/src/json/ext/Parser.java b/java/src/json/ext/Parser.java
77
- index ab3585e..6cb5886 100644
78
- --- a/java/src/json/ext/Parser.java
79
- +++ b/java/src/json/ext/Parser.java
80
- @@ -166,7 +166,7 @@ public class Parser extends RubyObject {
81
- this.symbolizeNames = opts.getBool("symbolize_names", false);
82
- this.quirksMode = opts.getBool("quirks_mode", false);
83
- this.createId = opts.getString("create_id", getCreateId(context));
84
- - this.createAdditions = opts.getBool("create_additions", true);
85
- + this.createAdditions = opts.getBool("create_additions", false);
86
- this.objectClass = opts.getClass("object_class", runtime.getHash());
87
- this.arrayClass = opts.getClass("array_class", runtime.getArray());
88
- this.match_string = opts.getHash("match_string");
89
- diff --git a/java/src/json/ext/Parser.rl b/java/src/json/ext/Parser.rl
90
- index e26637d..6dd335a 100644
91
- --- a/java/src/json/ext/Parser.rl
92
- +++ b/java/src/json/ext/Parser.rl
93
- @@ -164,7 +164,7 @@ public class Parser extends RubyObject {
94
- this.symbolizeNames = opts.getBool("symbolize_names", false);
95
- this.quirksMode = opts.getBool("quirks_mode", false);
96
- this.createId = opts.getString("create_id", getCreateId(context));
97
- - this.createAdditions = opts.getBool("create_additions", true);
98
- + this.createAdditions = opts.getBool("create_additions", false);
99
- this.objectClass = opts.getClass("object_class", runtime.getHash());
100
- this.arrayClass = opts.getClass("array_class", runtime.getArray());
101
- this.match_string = opts.getHash("match_string");
102
- diff --git a/json.gemspec b/json.gemspec
103
- index fb52be8..8d7c693 100644
104
- --- a/json.gemspec
105
- +++ b/json.gemspec
106
- @@ -6,7 +6,7 @@ Gem::Specification.new do |s|
107
-
108
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
109
- s.authors = ["Florian Frank"]
110
- - s.date = "2013-02-04"
111
- + s.date = "2013-02-10"
112
- s.description = "This is a JSON implementation as a Ruby extension in C."
113
- s.email = "flori@ping.de"
114
- s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb"]
115
- diff --git a/json_pure.gemspec b/json_pure.gemspec
116
- index 1d4b4c0..0d696c9 100644
117
- --- a/json_pure.gemspec
118
- +++ b/json_pure.gemspec
119
- @@ -6,7 +6,7 @@ Gem::Specification.new do |s|
120
-
121
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
122
- s.authors = ["Florian Frank"]
123
- - s.date = "2013-02-04"
124
- + s.date = "2013-02-10"
125
- s.description = "This is a JSON implementation in pure Ruby."
126
- s.email = "flori@ping.de"
127
- s.extra_rdoc_files = ["README.rdoc"]
128
- diff --git a/lib/json/common.rb b/lib/json/common.rb
129
- index 03892d9..65a74a1 100644
130
- --- a/lib/json/common.rb
131
- +++ b/lib/json/common.rb
132
- @@ -299,21 +299,28 @@ module JSON
133
- attr_accessor :load_default_options
134
- end
135
- self.load_default_options = {
136
- - :max_nesting => false,
137
- - :allow_nan => true,
138
- - :quirks_mode => true,
139
- + :max_nesting => false,
140
- + :allow_nan => true,
141
- + :quirks_mode => true,
142
- + :create_additions => true,
143
- }
144
-
145
- # Load a ruby data structure from a JSON _source_ and return it. A source can
146
- # either be a string-like object, an IO-like object, or an object responding
147
- # to the read method. If _proc_ was given, it will be called with any nested
148
- - # Ruby object as an argument recursively in depth first order. The default
149
- - # options for the parser can be changed via the load_default_options method.
150
- + # Ruby object as an argument recursively in depth first order. To modify the
151
- + # default options pass in the optional _options_ argument as well.
152
- + #
153
- + # BEWARE: This method is meant to serialise data from trusted user input,
154
- + # like from your own database server or clients under your control, it could
155
- + # be dangerous to allow untrusted users to pass JSON sources into it. The
156
- + # default options for the parser can be changed via the load_default_options
157
- + # method.
158
- #
159
- # This method is part of the implementation of the load/dump interface of
160
- # Marshal and YAML.
161
- - def load(source, proc = nil)
162
- - opts = load_default_options
163
- + def load(source, proc = nil, options = {})
164
- + opts = load_default_options.merge options
165
- if source.respond_to? :to_str
166
- source = source.to_str
167
- elsif source.respond_to? :to_io
168
- diff --git a/lib/json/generic_object.rb b/lib/json/generic_object.rb
169
- index cd93e1a..8b1074c 100644
170
- --- a/lib/json/generic_object.rb
171
- +++ b/lib/json/generic_object.rb
172
- @@ -5,6 +5,12 @@ module JSON
173
- class << self
174
- alias [] new
175
-
176
- + def json_creatable?
177
- + @json_creatable
178
- + end
179
- +
180
- + attr_writer :json_creatable
181
- +
182
- def json_create(data)
183
- data = data.dup
184
- data.delete JSON.create_id
185
- @@ -26,6 +32,7 @@ module JSON
186
- end
187
- end
188
- end
189
- + self.json_creatable = false
190
-
191
- def to_hash
192
- table
193
- diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb
194
- index cb249b2..a41d1ee 100644
195
- --- a/lib/json/pure/parser.rb
196
- +++ b/lib/json/pure/parser.rb
197
- @@ -63,9 +63,9 @@ module JSON
198
- # * *symbolize_names*: If set to true, returns symbols for the names
199
- # (keys) in a JSON object. Otherwise strings are returned, which is also
200
- # the default.
201
- - # * *create_additions*: If set to false, the Parser doesn't create
202
- - # additions even if a matchin class and create_id was found. This option
203
- - # defaults to true.
204
- + # * *create_additions*: If set to true, the Parser creates
205
- + # additions when if a matching class and create_id was found. This
206
- + # option defaults to false.
207
- # * *object_class*: Defaults to Hash
208
- # * *array_class*: Defaults to Array
209
- # * *quirks_mode*: Enables quirks_mode for parser, that is for example
210
- @@ -88,7 +88,7 @@ module JSON
211
- if opts.key?(:create_additions)
212
- @create_additions = !!opts[:create_additions]
213
- else
214
- - @create_additions = true
215
- + @create_additions = false
216
- end
217
- @create_id = @create_additions ? JSON.create_id : nil
218
- @object_class = opts[:object_class] || Hash
219
- diff --git a/tests/test_json.rb b/tests/test_json.rb
220
- index be974cd..6af6b32 100755
221
- --- a/tests/test_json.rb
222
- +++ b/tests/test_json.rb
223
- @@ -329,12 +329,12 @@ class TestJSON < Test::Unit::TestCase
224
- def test_generate_core_subclasses_with_new_to_json
225
- obj = SubHash2["foo" => SubHash2["bar" => true]]
226
- obj_json = JSON(obj)
227
- - obj_again = JSON(obj_json)
228
- + obj_again = JSON.parse(obj_json, :create_additions => true)
229
- assert_kind_of SubHash2, obj_again
230
- assert_kind_of SubHash2, obj_again['foo']
231
- assert obj_again['foo']['bar']
232
- assert_equal obj, obj_again
233
- - assert_equal ["foo"], JSON(JSON(SubArray2["foo"]))
234
- + assert_equal ["foo"], JSON(JSON(SubArray2["foo"]), :create_additions => true)
235
- end
236
-
237
- def test_generate_core_subclasses_with_default_to_json
238
- @@ -493,6 +493,12 @@ EOT
239
- assert_equal nil, JSON.load('')
240
- end
241
-
242
- + def test_load_with_options
243
- + small_hash = JSON("foo" => 'bar')
244
- + symbol_hash = { :foo => 'bar' }
245
- + assert_equal symbol_hash, JSON.load(small_hash, nil, :symbolize_names => true)
246
- + end
247
- +
248
- def test_dump
249
- too_deep = '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'
250
- assert_equal too_deep, JSON.dump(eval(too_deep))
251
- diff --git a/tests/test_json_addition.rb b/tests/test_json_addition.rb
252
- index 707aa32..a30f06a 100755
253
- --- a/tests/test_json_addition.rb
254
- +++ b/tests/test_json_addition.rb
255
- @@ -73,11 +73,19 @@ class TestJSONAddition < Test::Unit::TestCase
256
- a = A.new(666)
257
- assert A.json_creatable?
258
- json = generate(a)
259
- - a_again = JSON.parse(json)
260
- + a_again = JSON.parse(json, :create_additions => true)
261
- assert_kind_of a.class, a_again
262
- assert_equal a, a_again
263
- end
264
-
265
- + def test_extended_json_default
266
- + a = A.new(666)
267
- + assert A.json_creatable?
268
- + json = generate(a)
269
- + a_hash = JSON.parse(json)
270
- + assert_kind_of Hash, a_hash
271
- + end
272
- +
273
- def test_extended_json_disabled
274
- a = A.new(666)
275
- assert A.json_creatable?
276
- @@ -104,7 +112,7 @@ class TestJSONAddition < Test::Unit::TestCase
277
- c = C.new
278
- assert !C.json_creatable?
279
- json = generate(c)
280
- - assert_raises(ArgumentError, NameError) { JSON.parse(json) }
281
- + assert_raises(ArgumentError, NameError) { JSON.parse(json, :create_additions => true) }
282
- end
283
-
284
- def test_raw_strings
285
- @@ -122,7 +130,7 @@ class TestJSONAddition < Test::Unit::TestCase
286
- assert_match(/\A\{.*\}\z/, json)
287
- assert_match(/"json_class":"String"/, json)
288
- assert_match(/"raw":\[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255\]/, json)
289
- - raw_again = JSON.parse(json)
290
- + raw_again = JSON.parse(json, :create_additions => true)
291
- assert_equal raw, raw_again
292
- end
293
-
294
- @@ -130,17 +138,17 @@ class TestJSONAddition < Test::Unit::TestCase
295
-
296
- def test_core
297
- t = Time.now
298
- - assert_equal t, JSON(JSON(t))
299
- + assert_equal t, JSON(JSON(t), :create_additions => true)
300
- d = Date.today
301
- - assert_equal d, JSON(JSON(d))
302
- + assert_equal d, JSON(JSON(d), :create_additions => true)
303
- d = DateTime.civil(2007, 6, 14, 14, 57, 10, Rational(1, 12), 2299161)
304
- - assert_equal d, JSON(JSON(d))
305
- - assert_equal 1..10, JSON(JSON(1..10))
306
- - assert_equal 1...10, JSON(JSON(1...10))
307
- - assert_equal "a".."c", JSON(JSON("a".."c"))
308
- - assert_equal "a"..."c", JSON(JSON("a"..."c"))
309
- + assert_equal d, JSON(JSON(d), :create_additions => true)
310
- + assert_equal 1..10, JSON(JSON(1..10), :create_additions => true)
311
- + assert_equal 1...10, JSON(JSON(1...10), :create_additions => true)
312
- + assert_equal "a".."c", JSON(JSON("a".."c"), :create_additions => true)
313
- + assert_equal "a"..."c", JSON(JSON("a"..."c"), :create_additions => true)
314
- s = MyJsonStruct.new 4711, 'foot'
315
- - assert_equal s, JSON(JSON(s))
316
- + assert_equal s, JSON(JSON(s), :create_additions => true)
317
- struct = Struct.new :foo, :bar
318
- s = struct.new 4711, 'foot'
319
- assert_raises(JSONError) { JSON(s) }
320
- @@ -148,41 +156,41 @@ class TestJSONAddition < Test::Unit::TestCase
321
- raise TypeError, "test me"
322
- rescue TypeError => e
323
- e_json = JSON.generate e
324
- - e_again = JSON e_json
325
- + e_again = JSON e_json, :create_additions => true
326
- assert_kind_of TypeError, e_again
327
- assert_equal e.message, e_again.message
328
- assert_equal e.backtrace, e_again.backtrace
329
- end
330
- - assert_equal(/foo/, JSON(JSON(/foo/)))
331
- - assert_equal(/foo/i, JSON(JSON(/foo/i)))
332
- + assert_equal(/foo/, JSON(JSON(/foo/), :create_additions => true))
333
- + assert_equal(/foo/i, JSON(JSON(/foo/i), :create_additions => true))
334
- end
335
-
336
- def test_utc_datetime
337
- now = Time.now
338
- - d = DateTime.parse(now.to_s) # usual case
339
- - assert_equal d, JSON.parse(d.to_json)
340
- + d = DateTime.parse(now.to_s, :create_additions => true) # usual case
341
- + assert_equal d, JSON.parse(d.to_json, :create_additions => true)
342
- d = DateTime.parse(now.utc.to_s) # of = 0
343
- - assert_equal d, JSON.parse(d.to_json)
344
- + assert_equal d, JSON.parse(d.to_json, :create_additions => true)
345
- d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(1,24))
346
- - assert_equal d, JSON.parse(d.to_json)
347
- + assert_equal d, JSON.parse(d.to_json, :create_additions => true)
348
- d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(12,24))
349
- - assert_equal d, JSON.parse(d.to_json)
350
- + assert_equal d, JSON.parse(d.to_json, :create_additions => true)
351
- end
352
-
353
- def test_rational_complex
354
- - assert_equal Rational(2, 9), JSON(JSON(Rational(2, 9)))
355
- - assert_equal Complex(2, 9), JSON(JSON(Complex(2, 9)))
356
- + assert_equal Rational(2, 9), JSON.parse(JSON(Rational(2, 9)), :create_additions => true)
357
- + assert_equal Complex(2, 9), JSON.parse(JSON(Complex(2, 9)), :create_additions => true)
358
- end
359
-
360
- def test_bigdecimal
361
- - assert_equal BigDecimal('3.141', 23), JSON(JSON(BigDecimal('3.141', 23)))
362
- - assert_equal BigDecimal('3.141', 666), JSON(JSON(BigDecimal('3.141', 666)))
363
- + assert_equal BigDecimal('3.141', 23), JSON(JSON(BigDecimal('3.141', 23)), :create_additions => true)
364
- + assert_equal BigDecimal('3.141', 666), JSON(JSON(BigDecimal('3.141', 666)), :create_additions => true)
365
- end
366
-
367
- def test_ostruct
368
- o = OpenStruct.new
369
- # XXX this won't work; o.foo = { :bar => true }
370
- o.foo = { 'bar' => true }
371
- - assert_equal o, JSON(JSON(o))
372
- + assert_equal o, JSON.parse(JSON(o), :create_additions => true)
373
- end
374
- end
375
- diff --git a/tests/test_json_generic_object.rb b/tests/test_json_generic_object.rb
376
- index 83093b8..77ef22e 100644
377
- --- a/tests/test_json_generic_object.rb
378
- +++ b/tests/test_json_generic_object.rb
379
- @@ -20,17 +20,22 @@ class TestJSONGenericObject < Test::Unit::TestCase
380
- end
381
-
382
- def test_generate_json
383
- - assert_equal @go, JSON(JSON(@go))
384
- + switch_json_creatable do
385
- + assert_equal @go, JSON(JSON(@go), :create_additions => true)
386
- + end
387
- end
388
-
389
- def test_parse_json
390
- - assert_equal @go, l = JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }')
391
- - assert_equal 1, l.a
392
- - assert_equal @go, l = JSON('{ "a": 1, "b": 2 }', :object_class => GenericObject)
393
- - assert_equal 1, l.a
394
- - assert_equal GenericObject[:a => GenericObject[:b => 2]],
395
- - l = JSON('{ "a": { "b": 2 } }', :object_class => GenericObject)
396
- - assert_equal 2, l.a.b
397
- + assert_kind_of Hash, JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }', :create_additions => true)
398
- + switch_json_creatable do
399
- + assert_equal @go, l = JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }', :create_additions => true)
400
- + assert_equal 1, l.a
401
- + assert_equal @go, l = JSON('{ "a": 1, "b": 2 }', :object_class => GenericObject)
402
- + assert_equal 1, l.a
403
- + assert_equal GenericObject[:a => GenericObject[:b => 2]],
404
- + l = JSON('{ "a": { "b": 2 } }', :object_class => GenericObject)
405
- + assert_equal 2, l.a.b
406
- + end
407
- end
408
-
409
- def test_from_hash
410
- @@ -43,4 +48,13 @@ class TestJSONGenericObject < Test::Unit::TestCase
411
- assert_equal true, result.foo.quux.first.foobar
412
- assert_equal true, GenericObject.from_hash(true)
413
- end
414
- +
415
- + private
416
- +
417
- + def switch_json_creatable
418
- + JSON::GenericObject.json_creatable = true
419
- + yield
420
- + ensure
421
- + JSON::GenericObject.json_creatable = false
422
- + end
423
- end
424
- diff --git a/tests/test_json_string_matching.rb b/tests/test_json_string_matching.rb
425
- index 2ddedfa..c233df8 100644
426
- --- a/tests/test_json_string_matching.rb
427
- +++ b/tests/test_json_string_matching.rb
428
- @@ -27,14 +27,13 @@ class TestJSONStringMatching < Test::Unit::TestCase
429
- t = TestTime.new
430
- t_json = [ t ].to_json
431
- assert_equal [ t ],
432
- - JSON.parse(t_json,
433
- + JSON.parse(t_json, :create_additions => true,
434
- :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
435
- assert_equal [ t.strftime('%FT%T%z') ],
436
- - JSON.parse(t_json,
437
- + JSON.parse(t_json, :create_additions => true,
438
- :match_string => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
439
- assert_equal [ t.strftime('%FT%T%z') ],
440
- JSON.parse(t_json,
441
- - :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime },
442
- - :create_additions => false)
443
- + :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
444
- end
445
- end
446
- --
447
- 1.8.1.2
448
-
@@ -1,630 +0,0 @@
1
- From 79fa7f352bae842017c885101a556875600fb468 Mon Sep 17 00:00:00 2001
2
- From: Florian Frank <flori@ping.de>
3
- Date: Mon, 4 Feb 2013 23:28:30 +0100
4
- Subject: [PATCH] Security fix create_additons problem 1.5.5
5
-
6
- ---
7
- CHANGES | 7 ++++++
8
- Gemfile | 4 +++
9
- VERSION | 2 +-
10
- ext/json/ext/parser/parser.c | 36 +++++++++++++--------------
11
- ext/json/ext/parser/parser.rl | 5 +++-
12
- java/src/json/ext/Parser.java | 2 +-
13
- java/src/json/ext/Parser.rl | 2 +-
14
- json.gemspec | 10 ++++----
15
- json_pure.gemspec | 8 +++---
16
- lib/json/add/core.rb | 9 ++++---
17
- lib/json/common.rb | 17 +++++++++----
18
- lib/json/pure/parser.rb | 8 +++---
19
- lib/json/version.rb | 2 +-
20
- tests/test_json.rb | 24 ++++++++++++++++--
21
- tests/test_json_addition.rb | 50 ++++++++++++++++++++++----------------
22
- tests/test_json_string_matching.rb | 11 ++++-----
23
- 16 files changed, 124 insertions(+), 73 deletions(-)
24
-
25
- diff --git a/CHANGES b/CHANGES
26
- index 8e751be..42328b7 100644
27
- --- a/CHANGES
28
- +++ b/CHANGES
29
- @@ -1,3 +1,10 @@
30
- +2013-02-04 (1.5.5)
31
- + * Security fix for JSON create_additions default value. It should not be
32
- + possible to create additions unless
33
- + explicitely requested by setting the create_additions argument to true or
34
- + using the JSON.load/dump interface.
35
- + * Backport change that corrects Time serialisation/deserialisation on some
36
- + platforms.
37
- 2011-08-31 (1.5.4)
38
- * Fix memory leak when used from multiple JRuby. (Patch by
39
- jfirebaugh@github).
40
- diff --git a/Gemfile b/Gemfile
41
- index eb44418..e405da2 100644
42
- --- a/Gemfile
43
- +++ b/Gemfile
44
- @@ -5,3 +5,7 @@ source :rubygems
45
- gemspec :name => 'json'
46
- gemspec :name => 'json_pure'
47
- gemspec :name => 'json-java'
48
- +
49
- +gem 'utils'
50
- +gem 'test-unit'
51
- +gem 'debugger', :platform => :mri_19
52
- diff --git a/VERSION b/VERSION
53
- index 94fe62c..9075be4 100644
54
- --- a/VERSION
55
- +++ b/VERSION
56
- @@ -1 +1 @@
57
- -1.5.4
58
- +1.5.5
59
- diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
60
- index d1d14c7..21457c7 100644
61
- --- a/ext/json/ext/parser/parser.c
62
- +++ b/ext/json/ext/parser/parser.c
63
- @@ -1671,7 +1671,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
64
- if (option_given_p(opts, tmp)) {
65
- json->create_additions = RTEST(rb_hash_aref(opts, tmp));
66
- } else {
67
- - json->create_additions = 1;
68
- + json->create_additions = 0;
69
- }
70
- tmp = ID2SYM(i_create_id);
71
- if (option_given_p(opts, tmp)) {
72
- @@ -1718,7 +1718,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
73
- }
74
-
75
-
76
- -#line 1719 "parser.c"
77
- +#line 1722 "parser.c"
78
- static const int JSON_start = 1;
79
- static const int JSON_first_final = 10;
80
- static const int JSON_error = 0;
81
- @@ -1726,7 +1726,7 @@ static const int JSON_error = 0;
82
- static const int JSON_en_main = 1;
83
-
84
-
85
- -#line 726 "parser.rl"
86
- +#line 729 "parser.rl"
87
-
88
-
89
- static VALUE cParser_parse_strict(VALUE self)
90
- @@ -1737,16 +1737,16 @@ static VALUE cParser_parse_strict(VALUE self)
91
- GET_PARSER;
92
-
93
-
94
- -#line 1738 "parser.c"
95
- +#line 1741 "parser.c"
96
- {
97
- cs = JSON_start;
98
- }
99
-
100
- -#line 736 "parser.rl"
101
- +#line 739 "parser.rl"
102
- p = json->source;
103
- pe = p + json->len;
104
-
105
- -#line 1747 "parser.c"
106
- +#line 1750 "parser.c"
107
- {
108
- if ( p == pe )
109
- goto _test_eof;
110
- @@ -1802,7 +1802,7 @@ case 5:
111
- goto st1;
112
- goto st5;
113
- tr3:
114
- -#line 715 "parser.rl"
115
- +#line 718 "parser.rl"
116
- {
117
- char *np;
118
- json->current_nesting = 1;
119
- @@ -1811,7 +1811,7 @@ tr3:
120
- }
121
- goto st10;
122
- tr4:
123
- -#line 708 "parser.rl"
124
- +#line 711 "parser.rl"
125
- {
126
- char *np;
127
- json->current_nesting = 1;
128
- @@ -1823,7 +1823,7 @@ st10:
129
- if ( ++p == pe )
130
- goto _test_eof10;
131
- case 10:
132
- -#line 1824 "parser.c"
133
- +#line 1827 "parser.c"
134
- switch( (*p) ) {
135
- case 13: goto st10;
136
- case 32: goto st10;
137
- @@ -1880,7 +1880,7 @@ case 9:
138
- _out: {}
139
- }
140
-
141
- -#line 739 "parser.rl"
142
- +#line 742 "parser.rl"
143
-
144
- if (cs >= JSON_first_final && p == pe) {
145
- return result;
146
- @@ -1892,7 +1892,7 @@ case 9:
147
-
148
-
149
-
150
- -#line 1893 "parser.c"
151
- +#line 1896 "parser.c"
152
- static const int JSON_quirks_mode_start = 1;
153
- static const int JSON_quirks_mode_first_final = 10;
154
- static const int JSON_quirks_mode_error = 0;
155
- @@ -1900,7 +1900,7 @@ static const int JSON_quirks_mode_error = 0;
156
- static const int JSON_quirks_mode_en_main = 1;
157
-
158
-
159
- -#line 764 "parser.rl"
160
- +#line 767 "parser.rl"
161
-
162
-
163
- static VALUE cParser_parse_quirks_mode(VALUE self)
164
- @@ -1911,16 +1911,16 @@ static VALUE cParser_parse_quirks_mode(VALUE self)
165
- GET_PARSER;
166
-
167
-
168
- -#line 1912 "parser.c"
169
- +#line 1915 "parser.c"
170
- {
171
- cs = JSON_quirks_mode_start;
172
- }
173
-
174
- -#line 774 "parser.rl"
175
- +#line 777 "parser.rl"
176
- p = json->source;
177
- pe = p + json->len;
178
-
179
- -#line 1921 "parser.c"
180
- +#line 1924 "parser.c"
181
- {
182
- if ( p == pe )
183
- goto _test_eof;
184
- @@ -1954,7 +1954,7 @@ st0:
185
- cs = 0;
186
- goto _out;
187
- tr2:
188
- -#line 756 "parser.rl"
189
- +#line 759 "parser.rl"
190
- {
191
- char *np = JSON_parse_value(json, p, pe, &result);
192
- if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
193
- @@ -1964,7 +1964,7 @@ st10:
194
- if ( ++p == pe )
195
- goto _test_eof10;
196
- case 10:
197
- -#line 1965 "parser.c"
198
- +#line 1968 "parser.c"
199
- switch( (*p) ) {
200
- case 13: goto st10;
201
- case 32: goto st10;
202
- @@ -2053,7 +2053,7 @@ case 9:
203
- _out: {}
204
- }
205
-
206
- -#line 777 "parser.rl"
207
- +#line 780 "parser.rl"
208
-
209
- if (cs >= JSON_quirks_mode_first_final && p == pe) {
210
- return result;
211
- diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl
212
- index e7d47e1..ffde2ee 100644
213
- --- a/ext/json/ext/parser/parser.rl
214
- +++ b/ext/json/ext/parser/parser.rl
215
- @@ -602,6 +602,9 @@ static VALUE convert_encoding(VALUE source)
216
- * defaults to true.
217
- * * *object_class*: Defaults to Hash
218
- * * *array_class*: Defaults to Array
219
- + * * *quirks_mode*: Enables quirks_mode for parser, that is for example
220
- + * parsing single JSON values instead of documents is possible.
221
- + *
222
- */
223
- static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
224
- {
225
- @@ -652,7 +655,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
226
- if (option_given_p(opts, tmp)) {
227
- json->create_additions = RTEST(rb_hash_aref(opts, tmp));
228
- } else {
229
- - json->create_additions = 1;
230
- + json->create_additions = 0;
231
- }
232
- tmp = ID2SYM(i_create_id);
233
- if (option_given_p(opts, tmp)) {
234
- diff --git a/java/src/json/ext/Parser.java b/java/src/json/ext/Parser.java
235
- index 1240922..ee3d5ec 100644
236
- --- a/java/src/json/ext/Parser.java
237
- +++ b/java/src/json/ext/Parser.java
238
- @@ -160,7 +160,7 @@ public class Parser extends RubyObject {
239
- this.symbolizeNames = opts.getBool("symbolize_names", false);
240
- this.quirksMode = opts.getBool("quirks_mode", false);
241
- this.createId = opts.getString("create_id", getCreateId(context));
242
- - this.createAdditions = opts.getBool("create_additions", true);
243
- + this.createAdditions = opts.getBool("create_additions", false);
244
- this.objectClass = opts.getClass("object_class", runtime.getHash());
245
- this.arrayClass = opts.getClass("array_class", runtime.getArray());
246
- this.match_string = opts.getHash("match_string");
247
- diff --git a/java/src/json/ext/Parser.rl b/java/src/json/ext/Parser.rl
248
- index e8cd874..e9b3bbd 100644
249
- --- a/java/src/json/ext/Parser.rl
250
- +++ b/java/src/json/ext/Parser.rl
251
- @@ -162,7 +162,7 @@ public class Parser extends RubyObject {
252
- this.symbolizeNames = opts.getBool("symbolize_names", false);
253
- this.quirksMode = opts.getBool("quirks_mode", false);
254
- this.createId = opts.getString("create_id", getCreateId(context));
255
- - this.createAdditions = opts.getBool("create_additions", true);
256
- + this.createAdditions = opts.getBool("create_additions", false);
257
- this.objectClass = opts.getClass("object_class", runtime.getHash());
258
- this.arrayClass = opts.getClass("array_class", runtime.getArray());
259
- this.match_string = opts.getHash("match_string");
260
- diff --git a/json.gemspec b/json.gemspec
261
- index 344049a..ed8df20 100644
262
- --- a/json.gemspec
263
- +++ b/json.gemspec
264
- @@ -2,22 +2,22 @@
265
-
266
- Gem::Specification.new do |s|
267
- s.name = "json"
268
- - s.version = "1.5.4"
269
- + s.version = "1.5.5"
270
-
271
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
272
- s.authors = ["Florian Frank"]
273
- - s.date = "2011-08-31"
274
- + s.date = "2013-02-10"
275
- s.description = "This is a JSON implementation as a Ruby extension in C."
276
- s.email = "flori@ping.de"
277
- s.executables = ["edit_json.rb", "prettify_json.rb"]
278
- - s.extensions = ["ext/json/ext/parser/extconf.rb", "ext/json/ext/generator/extconf.rb"]
279
- + s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb"]
280
- s.extra_rdoc_files = ["README.rdoc"]
281
- - s.files = ["tests", "tests/test_json_string_matching.rb", "tests/test_json_fixtures.rb", "tests/setup_variant.rb", "tests/fixtures", "tests/fixtures/fail6.json", "tests/fixtures/fail9.json", "tests/fixtures/fail10.json", "tests/fixtures/fail24.json", "tests/fixtures/fail28.json", "tests/fixtures/fail13.json", "tests/fixtures/fail4.json", "tests/fixtures/pass3.json", "tests/fixtures/fail11.json", "tests/fixtures/fail14.json", "tests/fixtures/fail3.json", "tests/fixtures/fail12.json", "tests/fixtures/pass16.json", "tests/fixtures/pass15.json", "tests/fixtures/fail20.json", "tests/fixtures/fail8.json", "tests/fixtures/pass2.json", "tests/fixtures/fail5.json", "tests/fixtures/fail1.json", "tests/fixtures/fail25.json", "tests/fixtures/pass17.json", "tests/fixtures/fail7.json", "tests/fixtures/pass26.json", "tests/fixtures/fail21.json", "tests/fixtures/pass1.json", "tests/fixtures/fail23.json", "tests/fixtures/fail18.json", "tests/fixtures/fail2.json", "tests/fixtures/fail22.json", "tests/fixtures/fail27.json", "tests/fixtures/fail19.json", "tests/test_json_unicode.rb", "tests/test_json_addition.rb", "tests/test_json_generate.rb", "tests/test_json_encoding.rb", "tests/test_json.rb", "COPYING", "TODO", "Rakefile", "benchmarks", "benchmarks/data-p4-3GHz-ruby18", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat", "benchmarks/parser2_benchmark.rb", "benchmarks/parser_benchmark.rb", "benchmarks/generator2_benchmark.rb", "benchmarks/generator_benchmark.rb", "benchmarks/ohai.ruby", "benchmarks/data", "benchmarks/ohai.json", "lib", "lib/json", "lib/json/json.xpm", "lib/json/TrueClass.xpm", "lib/json/version.rb", "lib/json/Array.xpm", "lib/json/add", "lib/json/add/complex.rb", "lib/json/add/rational.rb", "lib/json/add/core.rb", "lib/json/common.rb", "lib/json/pure", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/ext.rb", "lib/json/pure.rb", "lib/json/Key.xpm", "lib/json/FalseClass.xpm", "lib/json/editor.rb", "lib/json/Numeric.xpm", "lib/json/ext", "lib/json/NilClass.xpm", "lib/json/String.xpm", "lib/json/Hash.xpm", "lib/json.rb", "Gemfile", "README.rdoc", "json_pure.gemspec", "GPL", "CHANGES", "bin", "bin/prettify_json.rb", "bin/edit_json.rb", "COPYING-json-jruby", "ext", "ext/json", "ext/json/ext", "ext/json/ext/parser", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.rl", "ext/json/ext/parser/parser.c", "ext/json/ext/generator", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.h", "VERSION", "data", "data/prototype.js", "data/index.html", "data/example.json", "json.gemspec", "java", "java/src", "java/src/json", "java/src/json/ext", "java/src/json/ext/Parser.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/ParserService.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/Utils.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/GeneratorMethods.java", "java/lib", "java/lib/bytelist-1.0.6.jar", "java/lib/jcodings.jar", "diagrams", "README-json-jruby.markdown", "install.rb", "json-java.gemspec", "tools", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
282
- + s.files = ["0001-Security-fix-create_additons-JSON-GenericObject.patch", "0001-Security-fix-create_additons-problem-1.5.5.patch", "0001-Security-fix-for-create_additions-problem-1.6.8.patch", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "Gemfile.lock", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "benchmarks", "benchmarks/data", "benchmarks/data-p4-3GHz-ruby18", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log", "benchmarks/generator2_benchmark.rb", "benchmarks/generator_benchmark.rb", "benchmarks/ohai.json", "benchmarks/ohai.ruby", "benchmarks/parser2_benchmark.rb", "benchmarks/parser_benchmark.rb", "bin", "bin/edit_json.rb", "bin/prettify_json.rb", "data", "data/example.json", "data/index.html", "data/prototype.js", "diagrams", "ext", "ext/json", "ext/json/ext", "ext/json/ext/generator", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "install.rb", "java", "java/lib", "java/lib/bytelist-1.0.6.jar", "java/lib/jcodings.jar", "java/src", "java/src/json", "java/src/json/ext", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib", "lib/json", "lib/json.rb", "lib/json/Array.xpm", "lib/json/FalseClass.xpm", "lib/json/Hash.xpm", "lib/json/Key.xpm", "lib/json/NilClass.xpm", "lib/json/Numeric.xpm", "lib/json/String.xpm", "lib/json/TrueClass.xpm", "lib/json/add", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/rational.rb", "lib/json/common.rb", "lib/json/editor.rb", "lib/json/ext", "lib/json/ext.rb", "lib/json/json.xpm", "lib/json/pure", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests", "tests/fixtures", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
283
- s.homepage = "http://flori.github.com/json"
284
- s.rdoc_options = ["--title", "JSON implemention for Ruby", "--main", "README.rdoc"]
285
- s.require_paths = ["ext/json/ext", "ext", "lib"]
286
- s.rubyforge_project = "json"
287
- - s.rubygems_version = "1.8.10"
288
- + s.rubygems_version = "1.8.25"
289
- s.summary = "JSON Implementation for Ruby"
290
- s.test_files = ["./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
291
-
292
- diff --git a/json_pure.gemspec b/json_pure.gemspec
293
- index f5f662e..d9356f4 100644
294
- --- a/json_pure.gemspec
295
- +++ b/json_pure.gemspec
296
- @@ -2,21 +2,21 @@
297
-
298
- Gem::Specification.new do |s|
299
- s.name = "json_pure"
300
- - s.version = "1.5.4"
301
- + s.version = "1.5.5"
302
-
303
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
304
- s.authors = ["Florian Frank"]
305
- - s.date = "2011-08-31"
306
- + s.date = "2013-02-10"
307
- s.description = "This is a JSON implementation in pure Ruby."
308
- s.email = "flori@ping.de"
309
- s.executables = ["edit_json.rb", "prettify_json.rb"]
310
- s.extra_rdoc_files = ["README.rdoc"]
311
- - s.files = ["tests", "tests/test_json_string_matching.rb", "tests/test_json_fixtures.rb", "tests/setup_variant.rb", "tests/fixtures", "tests/fixtures/fail6.json", "tests/fixtures/fail9.json", "tests/fixtures/fail10.json", "tests/fixtures/fail24.json", "tests/fixtures/fail28.json", "tests/fixtures/fail13.json", "tests/fixtures/fail4.json", "tests/fixtures/pass3.json", "tests/fixtures/fail11.json", "tests/fixtures/fail14.json", "tests/fixtures/fail3.json", "tests/fixtures/fail12.json", "tests/fixtures/pass16.json", "tests/fixtures/pass15.json", "tests/fixtures/fail20.json", "tests/fixtures/fail8.json", "tests/fixtures/pass2.json", "tests/fixtures/fail5.json", "tests/fixtures/fail1.json", "tests/fixtures/fail25.json", "tests/fixtures/pass17.json", "tests/fixtures/fail7.json", "tests/fixtures/pass26.json", "tests/fixtures/fail21.json", "tests/fixtures/pass1.json", "tests/fixtures/fail23.json", "tests/fixtures/fail18.json", "tests/fixtures/fail2.json", "tests/fixtures/fail22.json", "tests/fixtures/fail27.json", "tests/fixtures/fail19.json", "tests/test_json_unicode.rb", "tests/test_json_addition.rb", "tests/test_json_generate.rb", "tests/test_json_encoding.rb", "tests/test_json.rb", "COPYING", "TODO", "Rakefile", "benchmarks", "benchmarks/data-p4-3GHz-ruby18", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat", "benchmarks/parser2_benchmark.rb", "benchmarks/parser_benchmark.rb", "benchmarks/generator2_benchmark.rb", "benchmarks/generator_benchmark.rb", "benchmarks/ohai.ruby", "benchmarks/data", "benchmarks/ohai.json", "lib", "lib/json", "lib/json/json.xpm", "lib/json/TrueClass.xpm", "lib/json/version.rb", "lib/json/Array.xpm", "lib/json/add", "lib/json/add/complex.rb", "lib/json/add/rational.rb", "lib/json/add/core.rb", "lib/json/common.rb", "lib/json/pure", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/ext.rb", "lib/json/pure.rb", "lib/json/Key.xpm", "lib/json/FalseClass.xpm", "lib/json/editor.rb", "lib/json/Numeric.xpm", "lib/json/ext", "lib/json/NilClass.xpm", "lib/json/String.xpm", "lib/json/Hash.xpm", "lib/json.rb", "Gemfile", "README.rdoc", "json_pure.gemspec", "GPL", "CHANGES", "bin", "bin/prettify_json.rb", "bin/edit_json.rb", "COPYING-json-jruby", "ext", "ext/json", "ext/json/ext", "ext/json/ext/parser", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.rl", "ext/json/ext/parser/parser.c", "ext/json/ext/generator", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.h", "VERSION", "data", "data/prototype.js", "data/index.html", "data/example.json", "json.gemspec", "java", "java/src", "java/src/json", "java/src/json/ext", "java/src/json/ext/Parser.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/ParserService.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/Utils.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/GeneratorMethods.java", "java/lib", "java/lib/bytelist-1.0.6.jar", "java/lib/jcodings.jar", "diagrams", "README-json-jruby.markdown", "install.rb", "json-java.gemspec", "tools", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
312
- + s.files = ["0001-Security-fix-create_additons-JSON-GenericObject.patch", "0001-Security-fix-create_additons-problem-1.5.5.patch", "0001-Security-fix-for-create_additions-problem-1.6.8.patch", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "Gemfile.lock", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "benchmarks", "benchmarks/data", "benchmarks/data-p4-3GHz-ruby18", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log", "benchmarks/generator2_benchmark.rb", "benchmarks/generator_benchmark.rb", "benchmarks/ohai.json", "benchmarks/ohai.ruby", "benchmarks/parser2_benchmark.rb", "benchmarks/parser_benchmark.rb", "bin", "bin/edit_json.rb", "bin/prettify_json.rb", "data", "data/example.json", "data/index.html", "data/prototype.js", "diagrams", "ext", "ext/json", "ext/json/ext", "ext/json/ext/generator", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "install.rb", "java", "java/lib", "java/lib/bytelist-1.0.6.jar", "java/lib/jcodings.jar", "java/src", "java/src/json", "java/src/json/ext", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib", "lib/json", "lib/json.rb", "lib/json/Array.xpm", "lib/json/FalseClass.xpm", "lib/json/Hash.xpm", "lib/json/Key.xpm", "lib/json/NilClass.xpm", "lib/json/Numeric.xpm", "lib/json/String.xpm", "lib/json/TrueClass.xpm", "lib/json/add", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/rational.rb", "lib/json/common.rb", "lib/json/editor.rb", "lib/json/ext", "lib/json/ext.rb", "lib/json/json.xpm", "lib/json/pure", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests", "tests/fixtures", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
313
- s.homepage = "http://flori.github.com/json"
314
- s.rdoc_options = ["--title", "JSON implemention for ruby", "--main", "README.rdoc"]
315
- s.require_paths = ["lib"]
316
- s.rubyforge_project = "json"
317
- - s.rubygems_version = "1.8.10"
318
- + s.rubygems_version = "1.8.25"
319
- s.summary = "JSON Implementation for Ruby"
320
- s.test_files = ["./tests/test_json_string_matching.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_unicode.rb", "./tests/test_json_addition.rb", "./tests/test_json_generate.rb", "./tests/test_json_encoding.rb", "./tests/test_json.rb"]
321
-
322
- diff --git a/lib/json/add/core.rb b/lib/json/add/core.rb
323
- index 1ae00d0..01b8e04 100644
324
- --- a/lib/json/add/core.rb
325
- +++ b/lib/json/add/core.rb
326
- @@ -36,8 +36,8 @@ class Time
327
- if usec = object.delete('u') # used to be tv_usec -> tv_nsec
328
- object['n'] = usec * 1000
329
- end
330
- - if respond_to?(:tv_nsec)
331
- - at(*object.values_at('s', 'n'))
332
- + if instance_methods.include?(:tv_nsec)
333
- + at(object['s'], Rational(object['n'], 1000))
334
- else
335
- at(object['s'], object['n'] / 1000)
336
- end
337
- @@ -46,10 +46,13 @@ class Time
338
- # Returns a hash, that will be turned into a JSON object and represent this
339
- # object.
340
- def as_json(*)
341
- + nanoseconds = [ tv_usec * 1000 ]
342
- + respond_to?(:tv_nsec) and nanoseconds << tv_nsec
343
- + nanoseconds = nanoseconds.max
344
- {
345
- JSON.create_id => self.class.name,
346
- 's' => tv_sec,
347
- - 'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000
348
- + 'n' => nanoseconds,
349
- }
350
- end
351
-
352
- diff --git a/lib/json/common.rb b/lib/json/common.rb
353
- index 43e249c..9ad1fab 100644
354
- --- a/lib/json/common.rb
355
- +++ b/lib/json/common.rb
356
- @@ -141,7 +141,7 @@ module JSON
357
- # the default.
358
- # * *create_additions*: If set to false, the Parser doesn't create
359
- # additions even if a matching class and create_id was found. This option
360
- - # defaults to true.
361
- + # defaults to false.
362
- # * *object_class*: Defaults to Hash
363
- # * *array_class*: Defaults to Array
364
- def parse(source, opts = {})
365
- @@ -162,7 +162,7 @@ module JSON
366
- # to true.
367
- # * *create_additions*: If set to false, the Parser doesn't create
368
- # additions even if a matching class and create_id was found. This option
369
- - # defaults to true.
370
- + # defaults to false.
371
- def parse!(source, opts = {})
372
- opts = {
373
- :max_nesting => false,
374
- @@ -287,11 +287,18 @@ module JSON
375
- # Load a ruby data structure from a JSON _source_ and return it. A source can
376
- # either be a string-like object, an IO-like object, or an object responding
377
- # to the read method. If _proc_ was given, it will be called with any nested
378
- - # Ruby object as an argument recursively in depth first order.
379
- + # Ruby object as an argument recursively in depth first order. To modify the
380
- + # default options pass in the optional _options_ argument as well.
381
- #
382
- # This method is part of the implementation of the load/dump interface of
383
- # Marshal and YAML.
384
- - def load(source, proc = nil)
385
- + def load(source, proc = nil, options = {})
386
- + load_default_options = {
387
- + :max_nesting => false,
388
- + :allow_nan => true,
389
- + :create_additions => false
390
- + }
391
- + opts = load_default_options.merge options
392
- if source.respond_to? :to_str
393
- source = source.to_str
394
- elsif source.respond_to? :to_io
395
- @@ -299,7 +306,7 @@ module JSON
396
- else
397
- source = source.read
398
- end
399
- - result = parse(source, :max_nesting => false, :allow_nan => true)
400
- + result = parse(source, opts)
401
- recurse_proc(result, &proc) if proc
402
- result
403
- end
404
- diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb
405
- index e24aac1..d02ec34 100644
406
- --- a/lib/json/pure/parser.rb
407
- +++ b/lib/json/pure/parser.rb
408
- @@ -63,9 +63,9 @@ module JSON
409
- # * *symbolize_names*: If set to true, returns symbols for the names
410
- # (keys) in a JSON object. Otherwise strings are returned, which is also
411
- # the default.
412
- - # * *create_additions*: If set to false, the Parser doesn't create
413
- - # additions even if a matchin class and create_id was found. This option
414
- - # defaults to true.
415
- + # * *create_additions*: If set to true, the Parser creates
416
- + # additions when if a matching class and create_id was found. This
417
- + # option defaults to false.
418
- # * *object_class*: Defaults to Hash
419
- # * *array_class*: Defaults to Array
420
- # * *quirks_mode*: Enables quirks_mode for parser, that is for example
421
- @@ -88,7 +88,7 @@ module JSON
422
- if opts.key?(:create_additions)
423
- @create_additions = !!opts[:create_additions]
424
- else
425
- - @create_additions = true
426
- + @create_additions = false
427
- end
428
- @create_id = @create_additions ? JSON.create_id : nil
429
- @object_class = opts[:object_class] || Hash
430
- diff --git a/lib/json/version.rb b/lib/json/version.rb
431
- index 2175ac0..baacdc9 100644
432
- --- a/lib/json/version.rb
433
- +++ b/lib/json/version.rb
434
- @@ -1,6 +1,6 @@
435
- module JSON
436
- # JSON version
437
- - VERSION = '1.5.4'
438
- + VERSION = '1.5.5'
439
- VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
440
- VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
441
- VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
442
- diff --git a/tests/test_json.rb b/tests/test_json.rb
443
- index eafd758..fa96130 100755
444
- --- a/tests/test_json.rb
445
- +++ b/tests/test_json.rb
446
- @@ -4,6 +4,7 @@
447
- require 'test/unit'
448
- require File.join(File.dirname(__FILE__), 'setup_variant')
449
- require 'stringio'
450
- +require 'tempfile'
451
-
452
- unless Array.method_defined?(:permutation)
453
- begin
454
- @@ -263,12 +264,12 @@ class TC_JSON < Test::Unit::TestCase
455
- def test_generation_of_core_subclasses_with_new_to_json
456
- obj = SubHash2["foo" => SubHash2["bar" => true]]
457
- obj_json = JSON(obj)
458
- - obj_again = JSON(obj_json)
459
- + obj_again = JSON.parse(obj_json, :create_additions => true)
460
- assert_kind_of SubHash2, obj_again
461
- assert_kind_of SubHash2, obj_again['foo']
462
- assert obj_again['foo']['bar']
463
- assert_equal obj, obj_again
464
- - assert_equal ["foo"], JSON(JSON(SubArray2["foo"]))
465
- + assert_equal ["foo"], JSON(JSON(SubArray2["foo"]), :create_additions => true)
466
- end
467
-
468
- def test_generation_of_core_subclasses_with_default_to_json
469
- @@ -414,6 +415,25 @@ EOT
470
- JSON.parse('{"foo":"bar", "baz":"quux"}', :symbolize_names => true))
471
- end
472
-
473
- + def test_load
474
- + assert_equal @hash, JSON.load(@json)
475
- + tempfile = Tempfile.open('json')
476
- + tempfile.write @json
477
- + tempfile.rewind
478
- + assert_equal @hash, JSON.load(tempfile)
479
- + stringio = StringIO.new(@json)
480
- + stringio.rewind
481
- + assert_equal @hash, JSON.load(stringio)
482
- + assert_raise(NoMethodError) { JSON.load(nil) }
483
- + assert_raise(JSON::ParserError) {JSON.load('') }
484
- + end
485
- +
486
- + def test_load_with_options
487
- + small_hash = JSON("foo" => 'bar')
488
- + symbol_hash = { :foo => 'bar' }
489
- + assert_equal symbol_hash, JSON.load(small_hash, nil, :symbolize_names => true)
490
- + end
491
- +
492
- def test_load_dump
493
- too_deep = '[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]'
494
- assert_equal too_deep, JSON.dump(eval(too_deep))
495
- diff --git a/tests/test_json_addition.rb b/tests/test_json_addition.rb
496
- index 9f578a4..865880c 100755
497
- --- a/tests/test_json_addition.rb
498
- +++ b/tests/test_json_addition.rb
499
- @@ -71,11 +71,19 @@ class TC_JSONAddition < Test::Unit::TestCase
500
- a = A.new(666)
501
- assert A.json_creatable?
502
- json = generate(a)
503
- - a_again = JSON.parse(json)
504
- + a_again = JSON.parse(json, :create_additions => true)
505
- assert_kind_of a.class, a_again
506
- assert_equal a, a_again
507
- end
508
-
509
- + def test_extended_json_default
510
- + a = A.new(666)
511
- + assert A.json_creatable?
512
- + json = generate(a)
513
- + a_hash = JSON.parse(json)
514
- + assert_kind_of Hash, a_hash
515
- + end
516
- +
517
- def test_extended_json_disabled
518
- a = A.new(666)
519
- assert A.json_creatable?
520
- @@ -102,7 +110,7 @@ class TC_JSONAddition < Test::Unit::TestCase
521
- c = C.new
522
- assert !C.json_creatable?
523
- json = generate(c)
524
- - assert_raises(ArgumentError, NameError) { JSON.parse(json) }
525
- + assert_raises(ArgumentError, NameError) { JSON.parse(json, :create_additions => true) }
526
- end
527
-
528
- def test_raw_strings
529
- @@ -120,7 +128,7 @@ class TC_JSONAddition < Test::Unit::TestCase
530
- assert_match(/\A\{.*\}\Z/, json)
531
- assert_match(/"json_class":"String"/, json)
532
- assert_match(/"raw":\[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255\]/, json)
533
- - raw_again = JSON.parse(json)
534
- + raw_again = JSON.parse(json, :create_additions => true)
535
- assert_equal raw, raw_again
536
- end
537
-
538
- @@ -128,17 +136,17 @@ class TC_JSONAddition < Test::Unit::TestCase
539
-
540
- def test_core
541
- t = Time.now
542
- - assert_equal t.inspect, JSON(JSON(t)).inspect
543
- + assert_equal t, JSON(JSON(t), :create_additions => true)
544
- d = Date.today
545
- - assert_equal d, JSON(JSON(d))
546
- + assert_equal d, JSON(JSON(d), :create_additions => true)
547
- d = DateTime.civil(2007, 6, 14, 14, 57, 10, Rational(1, 12), 2299161)
548
- - assert_equal d, JSON(JSON(d))
549
- - assert_equal 1..10, JSON(JSON(1..10))
550
- - assert_equal 1...10, JSON(JSON(1...10))
551
- - assert_equal "a".."c", JSON(JSON("a".."c"))
552
- - assert_equal "a"..."c", JSON(JSON("a"..."c"))
553
- + assert_equal d, JSON(JSON(d), :create_additions => true)
554
- + assert_equal 1..10, JSON(JSON(1..10), :create_additions => true)
555
- + assert_equal 1...10, JSON(JSON(1...10), :create_additions => true)
556
- + assert_equal "a".."c", JSON(JSON("a".."c"), :create_additions => true)
557
- + assert_equal "a"..."c", JSON(JSON("a"..."c"), :create_additions => true)
558
- s = MyJsonStruct.new 4711, 'foot'
559
- - assert_equal s, JSON(JSON(s))
560
- + assert_equal s, JSON(JSON(s), :create_additions => true)
561
- struct = Struct.new :foo, :bar
562
- s = struct.new 4711, 'foot'
563
- assert_raises(JSONError) { JSON(s) }
564
- @@ -146,29 +154,29 @@ class TC_JSONAddition < Test::Unit::TestCase
565
- raise TypeError, "test me"
566
- rescue TypeError => e
567
- e_json = JSON.generate e
568
- - e_again = JSON e_json
569
- + e_again = JSON e_json, :create_additions => true
570
- assert_kind_of TypeError, e_again
571
- assert_equal e.message, e_again.message
572
- assert_equal e.backtrace, e_again.backtrace
573
- end
574
- - assert_equal(/foo/, JSON(JSON(/foo/)))
575
- - assert_equal(/foo/i, JSON(JSON(/foo/i)))
576
- + assert_equal(/foo/, JSON(JSON(/foo/), :create_additions => true))
577
- + assert_equal(/foo/i, JSON(JSON(/foo/i), :create_additions => true))
578
- end
579
-
580
- def test_utc_datetime
581
- now = Time.now
582
- - d = DateTime.parse(now.to_s) # usual case
583
- - assert_equal d, JSON.parse(d.to_json)
584
- + d = DateTime.parse(now.to_s, :create_additions => true) # usual case
585
- + assert_equal d, JSON.parse(d.to_json, :create_additions => true)
586
- d = DateTime.parse(now.utc.to_s) # of = 0
587
- - assert_equal d, JSON.parse(d.to_json)
588
- + assert_equal d, JSON.parse(d.to_json, :create_additions => true)
589
- d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(1,24))
590
- - assert_equal d, JSON.parse(d.to_json)
591
- + assert_equal d, JSON.parse(d.to_json, :create_additions => true)
592
- d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(12,24))
593
- - assert_equal d, JSON.parse(d.to_json)
594
- + assert_equal d, JSON.parse(d.to_json, :create_additions => true)
595
- end
596
-
597
- def test_rational_complex
598
- - assert_equal Rational(2, 9), JSON(JSON(Rational(2, 9)))
599
- - assert_equal Complex(2, 9), JSON(JSON(Complex(2, 9)))
600
- + assert_equal Rational(2, 9), JSON.parse(JSON(Rational(2, 9)), :create_additions => true)
601
- + assert_equal Complex(2, 9), JSON.parse(JSON(Complex(2, 9)), :create_additions => true)
602
- end
603
- end
604
- diff --git a/tests/test_json_string_matching.rb b/tests/test_json_string_matching.rb
605
- index df26a68..7335c0e 100644
606
- --- a/tests/test_json_string_matching.rb
607
- +++ b/tests/test_json_string_matching.rb
608
- @@ -27,14 +27,13 @@ class TestJsonStringMatching < Test::Unit::TestCase
609
- t = TestTime.new
610
- t_json = [ t ].to_json
611
- assert_equal [ t ],
612
- - JSON.parse(t_json,
613
- - :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime })
614
- + JSON.parse(t_json, :create_additions => true,
615
- + :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
616
- assert_equal [ t.strftime('%FT%T%z') ],
617
- - JSON.parse(t_json,
618
- - :match_string => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime })
619
- + JSON.parse(t_json, :create_additions => true,
620
- + :match_string => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
621
- assert_equal [ t.strftime('%FT%T%z') ],
622
- JSON.parse(t_json,
623
- - :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime },
624
- - :create_additions => false)
625
- + :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
626
- end
627
- end
628
- --
629
- 1.8.1.2
630
-