json 1.7.6 → 1.7.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of json might be problematic. Click here for more details.

data/CHANGES CHANGED
@@ -1,3 +1,17 @@
1
+ 2013-02-04 (1.7.7)
2
+ * Security fix for JSON create_additions default value and
3
+ JSON::GenericObject. It should not be possible to create additions unless
4
+ explicitely requested by setting the create_additions argument to true or
5
+ using the JSON.load/dump interface. If JSON::GenericObject is supposed to
6
+ be automatically deserialised, this has to be explicitely enabled by
7
+ setting
8
+ JSON::GenericObject.json_createble = true
9
+ as well.
10
+ * Remove useless assert in fbuffer implementation.
11
+ * Apply patch attached to https://github.com/flori/json/issues#issue/155
12
+ provided by John Shahid <jvshahid@gmail.com>, Thx!
13
+ * Add license information to rubygems spec data, reported by Jordi Massaguer Pla <jmassaguerpla@suse.de>.
14
+ * Improve documentation, thx to Zachary Scott <zachary@zacharyscott.net>.
1
15
  2012-11-29 (1.7.6)
2
16
  * Add GeneratorState#merge alias for JRuby, fix state accessor methods. Thx to
3
17
  jvshahid@github.
data/Gemfile CHANGED
@@ -7,3 +7,5 @@ gemspec :name => 'json_pure'
7
7
  gemspec :name => 'json-java'
8
8
 
9
9
  gem 'utils'
10
+ gem 'test-unit'
11
+ gem 'debugger', :platform => :mri_19
data/Rakefile CHANGED
@@ -88,7 +88,7 @@ if defined?(Gem) and defined?(Gem::PackageTask)
88
88
 
89
89
  s.require_path = 'lib'
90
90
  s.add_development_dependency 'permutation'
91
- s.add_development_dependency 'sdoc', '~> 0.3.16'
91
+ s.add_development_dependency 'sdoc', '~>0.3.16'
92
92
  s.add_development_dependency 'rake', '~>0.9.2'
93
93
 
94
94
  s.extra_rdoc_files << 'README.rdoc'
@@ -99,7 +99,7 @@ if defined?(Gem) and defined?(Gem::PackageTask)
99
99
  s.author = "Florian Frank"
100
100
  s.email = "flori@ping.de"
101
101
  s.homepage = "http://flori.github.com/#{PKG_NAME}"
102
- s.rubyforge_project = "json"
102
+ s.license = 'Ruby'
103
103
  end
104
104
 
105
105
  desc 'Creates a json_pure.gemspec file'
@@ -126,7 +126,7 @@ if defined?(Gem) and defined?(Gem::PackageTask)
126
126
 
127
127
  s.require_path = 'lib'
128
128
  s.add_development_dependency 'permutation'
129
- s.add_development_dependency 'sdoc', '~> 0.3.16'
129
+ s.add_development_dependency 'sdoc', '~>0.3.16'
130
130
 
131
131
  s.extra_rdoc_files << 'README.rdoc'
132
132
  s.rdoc_options <<
@@ -136,7 +136,7 @@ if defined?(Gem) and defined?(Gem::PackageTask)
136
136
  s.author = "Florian Frank"
137
137
  s.email = "flori@ping.de"
138
138
  s.homepage = "http://flori.github.com/#{PKG_NAME}"
139
- s.rubyforge_project = "json"
139
+ s.license = 'Ruby'
140
140
  end
141
141
 
142
142
  desc 'Creates a json.gemspec file'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.6
1
+ 1.7.7
@@ -3,7 +3,6 @@
3
3
  #define _FBUFFER_H_
4
4
 
5
5
  #include "ruby.h"
6
- #include <assert.h>
7
6
 
8
7
  #ifndef RHASH_SIZE
9
8
  #define RHASH_SIZE(hsh) (RHASH(hsh)->tbl->num_entries)
@@ -166,11 +165,8 @@ static FBuffer *fbuffer_dup(FBuffer *fb)
166
165
  unsigned long len = fb->len;
167
166
  FBuffer *result;
168
167
 
169
- assert(len > 0);
170
- if (len > 0) {
171
- result = fbuffer_alloc(len);
172
- fbuffer_append(result, FBUFFER_PAIR(fb));
173
- }
168
+ result = fbuffer_alloc(len);
169
+ fbuffer_append(result, FBUFFER_PAIR(fb));
174
170
  return result;
175
171
  }
176
172
 
@@ -2,7 +2,6 @@
2
2
  #define _GENERATOR_H_
3
3
 
4
4
  #include <string.h>
5
- #include <assert.h>
6
5
  #include <math.h>
7
6
  #include <ctype.h>
8
7
 
@@ -1680,7 +1680,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1680
1680
  if (option_given_p(opts, tmp)) {
1681
1681
  json->create_additions = RTEST(rb_hash_aref(opts, tmp));
1682
1682
  } else {
1683
- json->create_additions = 1;
1683
+ json->create_additions = 0;
1684
1684
  }
1685
1685
  tmp = ID2SYM(i_create_id);
1686
1686
  if (option_given_p(opts, tmp)) {
@@ -664,7 +664,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
664
664
  if (option_given_p(opts, tmp)) {
665
665
  json->create_additions = RTEST(rb_hash_aref(opts, tmp));
666
666
  } else {
667
- json->create_additions = 1;
667
+ json->create_additions = 0;
668
668
  }
669
669
  tmp = ID2SYM(i_create_id);
670
670
  if (option_given_p(opts, tmp)) {
@@ -263,7 +263,8 @@ public class GeneratorState extends RubyObject {
263
263
  if (getMetaClass().isMethodBound(name, true)) {
264
264
  return send(context, vName, Block.NULL_BLOCK);
265
265
  } else {
266
- return getInstanceVariables().getInstanceVariable("@" + name);
266
+ IRubyObject value = getInstanceVariables().getInstanceVariable("@" + name);
267
+ return value == null ? context.nil : value;
267
268
  }
268
269
  }
269
270
 
@@ -166,7 +166,7 @@ public class Parser extends RubyObject {
166
166
  this.symbolizeNames = opts.getBool("symbolize_names", false);
167
167
  this.quirksMode = opts.getBool("quirks_mode", false);
168
168
  this.createId = opts.getString("create_id", getCreateId(context));
169
- this.createAdditions = opts.getBool("create_additions", true);
169
+ this.createAdditions = opts.getBool("create_additions", false);
170
170
  this.objectClass = opts.getClass("object_class", runtime.getHash());
171
171
  this.arrayClass = opts.getClass("array_class", runtime.getArray());
172
172
  this.match_string = opts.getHash("match_string");
@@ -164,7 +164,7 @@ public class Parser extends RubyObject {
164
164
  this.symbolizeNames = opts.getBool("symbolize_names", false);
165
165
  this.quirksMode = opts.getBool("quirks_mode", false);
166
166
  this.createId = opts.getString("create_id", getCreateId(context));
167
- this.createAdditions = opts.getBool("create_additions", true);
167
+ this.createAdditions = opts.getBool("create_additions", false);
168
168
  this.objectClass = opts.getClass("object_class", runtime.getHash());
169
169
  this.arrayClass = opts.getClass("array_class", runtime.getArray());
170
170
  this.match_string = opts.getHash("match_string");
@@ -11,6 +11,7 @@ spec = Gem::Specification.new do |s|
11
11
  s.homepage = "http://json-jruby.rubyforge.org/"
12
12
  s.platform = 'java'
13
13
  s.rubyforge_project = "json-jruby"
14
+ s.license = "Ruby"
14
15
 
15
16
  s.files = Dir["{docs,lib,tests}/**/*"]
16
17
  end
@@ -2,23 +2,23 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "json"
5
- s.version = "1.7.6"
5
+ s.version = "1.7.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Florian Frank"]
9
- s.date = "2012-12-31"
9
+ s.date = "2013-02-11"
10
10
  s.description = "This is a JSON implementation as a Ruby extension in C."
11
11
  s.email = "flori@ping.de"
12
12
  s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb"]
13
13
  s.extra_rdoc_files = ["README.rdoc"]
14
- s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/depend", "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/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/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/generic_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "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_generic_object.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "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_generic_object.rb", "./tests/test_json.rb"]
14
+ s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/depend", "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/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/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/generic_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "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_generic_object.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/fuzz.rb", "tools/server.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_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
15
15
  s.homepage = "http://flori.github.com/json"
16
+ s.licenses = ["Ruby"]
16
17
  s.rdoc_options = ["--title", "JSON implemention for Ruby", "--main", "README.rdoc"]
17
18
  s.require_paths = ["lib"]
18
- s.rubyforge_project = "json"
19
- s.rubygems_version = "1.8.24"
19
+ s.rubygems_version = "1.8.25"
20
20
  s.summary = "JSON Implementation for Ruby"
21
- 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_generic_object.rb", "./tests/test_json.rb"]
21
+ s.test_files = ["./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_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
22
22
 
23
23
  if s.respond_to? :specification_version then
24
24
  s.specification_version = 3
@@ -2,22 +2,22 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "json_pure"
5
- s.version = "1.7.6"
5
+ s.version = "1.7.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Florian Frank"]
9
- s.date = "2012-12-31"
9
+ s.date = "2013-02-11"
10
10
  s.description = "This is a JSON implementation in pure Ruby."
11
11
  s.email = "flori@ping.de"
12
12
  s.extra_rdoc_files = ["README.rdoc"]
13
- s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/depend", "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/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/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/generic_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "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_generic_object.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "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_generic_object.rb", "./tests/test_json.rb"]
13
+ s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/depend", "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/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/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/generic_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "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_generic_object.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/fuzz.rb", "tools/server.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_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
14
14
  s.homepage = "http://flori.github.com/json"
15
+ s.licenses = ["Ruby"]
15
16
  s.rdoc_options = ["--title", "JSON implemention for ruby", "--main", "README.rdoc"]
16
17
  s.require_paths = ["lib"]
17
- s.rubyforge_project = "json"
18
- s.rubygems_version = "1.8.24"
18
+ s.rubygems_version = "1.8.25"
19
19
  s.summary = "JSON Implementation for Ruby"
20
- 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_generic_object.rb", "./tests/test_json.rb"]
20
+ s.test_files = ["./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_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
21
21
 
22
22
  if s.respond_to? :specification_version then
23
23
  s.specification_version = 3
@@ -1,3 +1,5 @@
1
+ require 'json/common'
2
+
1
3
  ##
2
4
  # = JavaScript Object Notation (JSON)
3
5
  #
@@ -49,8 +51,6 @@
49
51
  #
50
52
  # 1.to_json => "1"
51
53
  #
52
-
53
- require 'json/common'
54
54
  module JSON
55
55
  require 'json/version'
56
56
 
@@ -299,21 +299,28 @@ module JSON
299
299
  attr_accessor :load_default_options
300
300
  end
301
301
  self.load_default_options = {
302
- :max_nesting => false,
303
- :allow_nan => true,
304
- :quirks_mode => true,
302
+ :max_nesting => false,
303
+ :allow_nan => true,
304
+ :quirks_mode => true,
305
+ :create_additions => true,
305
306
  }
306
307
 
307
308
  # Load a ruby data structure from a JSON _source_ and return it. A source can
308
309
  # either be a string-like object, an IO-like object, or an object responding
309
310
  # to the read method. If _proc_ was given, it will be called with any nested
310
- # Ruby object as an argument recursively in depth first order. The default
311
- # options for the parser can be changed via the load_default_options method.
311
+ # Ruby object as an argument recursively in depth first order. To modify the
312
+ # default options pass in the optional _options_ argument as well.
313
+ #
314
+ # BEWARE: This method is meant to serialise data from trusted user input,
315
+ # like from your own database server or clients under your control, it could
316
+ # be dangerous to allow untrusted users to pass JSON sources into it. The
317
+ # default options for the parser can be changed via the load_default_options
318
+ # method.
312
319
  #
313
320
  # This method is part of the implementation of the load/dump interface of
314
321
  # Marshal and YAML.
315
- def load(source, proc = nil)
316
- opts = load_default_options
322
+ def load(source, proc = nil, options = {})
323
+ opts = load_default_options.merge options
317
324
  if source.respond_to? :to_str
318
325
  source = source.to_str
319
326
  elsif source.respond_to? :to_io
@@ -5,6 +5,12 @@ module JSON
5
5
  class << self
6
6
  alias [] new
7
7
 
8
+ def json_creatable?
9
+ @json_creatable
10
+ end
11
+
12
+ attr_writer :json_creatable
13
+
8
14
  def json_create(data)
9
15
  data = data.dup
10
16
  data.delete JSON.create_id
@@ -26,6 +32,7 @@ module JSON
26
32
  end
27
33
  end
28
34
  end
35
+ self.json_creatable = false
29
36
 
30
37
  def to_hash
31
38
  table
@@ -63,9 +63,9 @@ module JSON
63
63
  # * *symbolize_names*: If set to true, returns symbols for the names
64
64
  # (keys) in a JSON object. Otherwise strings are returned, which is also
65
65
  # the default.
66
- # * *create_additions*: If set to false, the Parser doesn't create
67
- # additions even if a matchin class and create_id was found. This option
68
- # defaults to true.
66
+ # * *create_additions*: If set to true, the Parser creates
67
+ # additions when if a matching class and create_id was found. This
68
+ # option defaults to false.
69
69
  # * *object_class*: Defaults to Hash
70
70
  # * *array_class*: Defaults to Array
71
71
  # * *quirks_mode*: Enables quirks_mode for parser, that is for example
@@ -88,7 +88,7 @@ module JSON
88
88
  if opts.key?(:create_additions)
89
89
  @create_additions = !!opts[:create_additions]
90
90
  else
91
- @create_additions = true
91
+ @create_additions = false
92
92
  end
93
93
  @create_id = @create_additions ? JSON.create_id : nil
94
94
  @object_class = opts[:object_class] || Hash
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.7.6'
3
+ VERSION = '1.7.7'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -329,12 +329,12 @@ class TestJSON < Test::Unit::TestCase
329
329
  def test_generate_core_subclasses_with_new_to_json
330
330
  obj = SubHash2["foo" => SubHash2["bar" => true]]
331
331
  obj_json = JSON(obj)
332
- obj_again = JSON(obj_json)
332
+ obj_again = JSON.parse(obj_json, :create_additions => true)
333
333
  assert_kind_of SubHash2, obj_again
334
334
  assert_kind_of SubHash2, obj_again['foo']
335
335
  assert obj_again['foo']['bar']
336
336
  assert_equal obj, obj_again
337
- assert_equal ["foo"], JSON(JSON(SubArray2["foo"]))
337
+ assert_equal ["foo"], JSON(JSON(SubArray2["foo"]), :create_additions => true)
338
338
  end
339
339
 
340
340
  def test_generate_core_subclasses_with_default_to_json
@@ -493,6 +493,12 @@ EOT
493
493
  assert_equal nil, JSON.load('')
494
494
  end
495
495
 
496
+ def test_load_with_options
497
+ small_hash = JSON("foo" => 'bar')
498
+ symbol_hash = { :foo => 'bar' }
499
+ assert_equal symbol_hash, JSON.load(small_hash, nil, :symbolize_names => true)
500
+ end
501
+
496
502
  def test_dump
497
503
  too_deep = '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'
498
504
  assert_equal too_deep, JSON.dump(eval(too_deep))
@@ -73,11 +73,19 @@ class TestJSONAddition < Test::Unit::TestCase
73
73
  a = A.new(666)
74
74
  assert A.json_creatable?
75
75
  json = generate(a)
76
- a_again = JSON.parse(json)
76
+ a_again = JSON.parse(json, :create_additions => true)
77
77
  assert_kind_of a.class, a_again
78
78
  assert_equal a, a_again
79
79
  end
80
80
 
81
+ def test_extended_json_default
82
+ a = A.new(666)
83
+ assert A.json_creatable?
84
+ json = generate(a)
85
+ a_hash = JSON.parse(json)
86
+ assert_kind_of Hash, a_hash
87
+ end
88
+
81
89
  def test_extended_json_disabled
82
90
  a = A.new(666)
83
91
  assert A.json_creatable?
@@ -104,7 +112,7 @@ class TestJSONAddition < Test::Unit::TestCase
104
112
  c = C.new
105
113
  assert !C.json_creatable?
106
114
  json = generate(c)
107
- assert_raises(ArgumentError, NameError) { JSON.parse(json) }
115
+ assert_raises(ArgumentError, NameError) { JSON.parse(json, :create_additions => true) }
108
116
  end
109
117
 
110
118
  def test_raw_strings
@@ -122,7 +130,7 @@ class TestJSONAddition < Test::Unit::TestCase
122
130
  assert_match(/\A\{.*\}\z/, json)
123
131
  assert_match(/"json_class":"String"/, json)
124
132
  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)
125
- raw_again = JSON.parse(json)
133
+ raw_again = JSON.parse(json, :create_additions => true)
126
134
  assert_equal raw, raw_again
127
135
  end
128
136
 
@@ -130,17 +138,17 @@ class TestJSONAddition < Test::Unit::TestCase
130
138
 
131
139
  def test_core
132
140
  t = Time.now
133
- assert_equal t, JSON(JSON(t))
141
+ assert_equal t, JSON(JSON(t), :create_additions => true)
134
142
  d = Date.today
135
- assert_equal d, JSON(JSON(d))
143
+ assert_equal d, JSON(JSON(d), :create_additions => true)
136
144
  d = DateTime.civil(2007, 6, 14, 14, 57, 10, Rational(1, 12), 2299161)
137
- assert_equal d, JSON(JSON(d))
138
- assert_equal 1..10, JSON(JSON(1..10))
139
- assert_equal 1...10, JSON(JSON(1...10))
140
- assert_equal "a".."c", JSON(JSON("a".."c"))
141
- assert_equal "a"..."c", JSON(JSON("a"..."c"))
145
+ assert_equal d, JSON(JSON(d), :create_additions => true)
146
+ assert_equal 1..10, JSON(JSON(1..10), :create_additions => true)
147
+ assert_equal 1...10, JSON(JSON(1...10), :create_additions => true)
148
+ assert_equal "a".."c", JSON(JSON("a".."c"), :create_additions => true)
149
+ assert_equal "a"..."c", JSON(JSON("a"..."c"), :create_additions => true)
142
150
  s = MyJsonStruct.new 4711, 'foot'
143
- assert_equal s, JSON(JSON(s))
151
+ assert_equal s, JSON(JSON(s), :create_additions => true)
144
152
  struct = Struct.new :foo, :bar
145
153
  s = struct.new 4711, 'foot'
146
154
  assert_raises(JSONError) { JSON(s) }
@@ -148,41 +156,41 @@ class TestJSONAddition < Test::Unit::TestCase
148
156
  raise TypeError, "test me"
149
157
  rescue TypeError => e
150
158
  e_json = JSON.generate e
151
- e_again = JSON e_json
159
+ e_again = JSON e_json, :create_additions => true
152
160
  assert_kind_of TypeError, e_again
153
161
  assert_equal e.message, e_again.message
154
162
  assert_equal e.backtrace, e_again.backtrace
155
163
  end
156
- assert_equal(/foo/, JSON(JSON(/foo/)))
157
- assert_equal(/foo/i, JSON(JSON(/foo/i)))
164
+ assert_equal(/foo/, JSON(JSON(/foo/), :create_additions => true))
165
+ assert_equal(/foo/i, JSON(JSON(/foo/i), :create_additions => true))
158
166
  end
159
167
 
160
168
  def test_utc_datetime
161
169
  now = Time.now
162
- d = DateTime.parse(now.to_s) # usual case
163
- assert_equal d, JSON.parse(d.to_json)
170
+ d = DateTime.parse(now.to_s, :create_additions => true) # usual case
171
+ assert_equal d, JSON.parse(d.to_json, :create_additions => true)
164
172
  d = DateTime.parse(now.utc.to_s) # of = 0
165
- assert_equal d, JSON.parse(d.to_json)
173
+ assert_equal d, JSON.parse(d.to_json, :create_additions => true)
166
174
  d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(1,24))
167
- assert_equal d, JSON.parse(d.to_json)
175
+ assert_equal d, JSON.parse(d.to_json, :create_additions => true)
168
176
  d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(12,24))
169
- assert_equal d, JSON.parse(d.to_json)
177
+ assert_equal d, JSON.parse(d.to_json, :create_additions => true)
170
178
  end
171
179
 
172
180
  def test_rational_complex
173
- assert_equal Rational(2, 9), JSON(JSON(Rational(2, 9)))
174
- assert_equal Complex(2, 9), JSON(JSON(Complex(2, 9)))
181
+ assert_equal Rational(2, 9), JSON.parse(JSON(Rational(2, 9)), :create_additions => true)
182
+ assert_equal Complex(2, 9), JSON.parse(JSON(Complex(2, 9)), :create_additions => true)
175
183
  end
176
184
 
177
185
  def test_bigdecimal
178
- assert_equal BigDecimal('3.141', 23), JSON(JSON(BigDecimal('3.141', 23)))
179
- assert_equal BigDecimal('3.141', 666), JSON(JSON(BigDecimal('3.141', 666)))
186
+ assert_equal BigDecimal('3.141', 23), JSON(JSON(BigDecimal('3.141', 23)), :create_additions => true)
187
+ assert_equal BigDecimal('3.141', 666), JSON(JSON(BigDecimal('3.141', 666)), :create_additions => true)
180
188
  end
181
189
 
182
190
  def test_ostruct
183
191
  o = OpenStruct.new
184
192
  # XXX this won't work; o.foo = { :bar => true }
185
193
  o.foo = { 'bar' => true }
186
- assert_equal o, JSON(JSON(o))
194
+ assert_equal o, JSON.parse(JSON(o), :create_additions => true)
187
195
  end
188
196
  end
@@ -276,6 +276,7 @@ EOT
276
276
  def test_hash_likeness_set_symbol
277
277
  state = JSON.state.new
278
278
  assert_equal nil, state[:foo]
279
+ assert_equal nil.class, state[:foo].class
279
280
  assert_equal nil, state['foo']
280
281
  state[:foo] = :bar
281
282
  assert_equal :bar, state[:foo]
@@ -20,17 +20,22 @@ class TestJSONGenericObject < Test::Unit::TestCase
20
20
  end
21
21
 
22
22
  def test_generate_json
23
- assert_equal @go, JSON(JSON(@go))
23
+ switch_json_creatable do
24
+ assert_equal @go, JSON(JSON(@go), :create_additions => true)
25
+ end
24
26
  end
25
27
 
26
28
  def test_parse_json
27
- assert_equal @go, l = JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }')
28
- assert_equal 1, l.a
29
- assert_equal @go, l = JSON('{ "a": 1, "b": 2 }', :object_class => GenericObject)
30
- assert_equal 1, l.a
31
- assert_equal GenericObject[:a => GenericObject[:b => 2]],
32
- l = JSON('{ "a": { "b": 2 } }', :object_class => GenericObject)
33
- assert_equal 2, l.a.b
29
+ assert_kind_of Hash, JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }', :create_additions => true)
30
+ switch_json_creatable do
31
+ assert_equal @go, l = JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }', :create_additions => true)
32
+ assert_equal 1, l.a
33
+ assert_equal @go, l = JSON('{ "a": 1, "b": 2 }', :object_class => GenericObject)
34
+ assert_equal 1, l.a
35
+ assert_equal GenericObject[:a => GenericObject[:b => 2]],
36
+ l = JSON('{ "a": { "b": 2 } }', :object_class => GenericObject)
37
+ assert_equal 2, l.a.b
38
+ end
34
39
  end
35
40
 
36
41
  def test_from_hash
@@ -43,4 +48,13 @@ class TestJSONGenericObject < Test::Unit::TestCase
43
48
  assert_equal true, result.foo.quux.first.foobar
44
49
  assert_equal true, GenericObject.from_hash(true)
45
50
  end
51
+
52
+ private
53
+
54
+ def switch_json_creatable
55
+ JSON::GenericObject.json_creatable = true
56
+ yield
57
+ ensure
58
+ JSON::GenericObject.json_creatable = false
59
+ end
46
60
  end
@@ -27,14 +27,13 @@ class TestJSONStringMatching < Test::Unit::TestCase
27
27
  t = TestTime.new
28
28
  t_json = [ t ].to_json
29
29
  assert_equal [ t ],
30
- JSON.parse(t_json,
30
+ JSON.parse(t_json, :create_additions => true,
31
31
  :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
32
32
  assert_equal [ t.strftime('%FT%T%z') ],
33
- JSON.parse(t_json,
33
+ JSON.parse(t_json, :create_additions => true,
34
34
  :match_string => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
35
35
  assert_equal [ t.strftime('%FT%T%z') ],
36
36
  JSON.parse(t_json,
37
- :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime },
38
- :create_additions => false)
37
+ :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
39
38
  end
40
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.6
4
+ version: 1.7.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-31 00:00:00.000000000 Z
12
+ date: 2013-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: permutation
@@ -159,16 +159,17 @@ files:
159
159
  - tests/test_json_unicode.rb
160
160
  - tools/fuzz.rb
161
161
  - tools/server.rb
162
- - ./tests/test_json_string_matching.rb
163
- - ./tests/test_json_fixtures.rb
164
- - ./tests/test_json_unicode.rb
162
+ - ./tests/test_json.rb
165
163
  - ./tests/test_json_addition.rb
166
- - ./tests/test_json_generate.rb
167
164
  - ./tests/test_json_encoding.rb
165
+ - ./tests/test_json_fixtures.rb
166
+ - ./tests/test_json_generate.rb
168
167
  - ./tests/test_json_generic_object.rb
169
- - ./tests/test_json.rb
168
+ - ./tests/test_json_string_matching.rb
169
+ - ./tests/test_json_unicode.rb
170
170
  homepage: http://flori.github.com/json
171
- licenses: []
171
+ licenses:
172
+ - Ruby
172
173
  post_install_message:
173
174
  rdoc_options:
174
175
  - --title
@@ -185,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
186
  version: '0'
186
187
  segments:
187
188
  - 0
188
- hash: -365926163349180863
189
+ hash: -3737191669219953404
189
190
  required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  none: false
191
192
  requirements:
@@ -193,17 +194,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
194
  - !ruby/object:Gem::Version
194
195
  version: '0'
195
196
  requirements: []
196
- rubyforge_project: json
197
- rubygems_version: 1.8.24
197
+ rubyforge_project:
198
+ rubygems_version: 1.8.25
198
199
  signing_key:
199
200
  specification_version: 3
200
201
  summary: JSON Implementation for Ruby
201
202
  test_files:
202
- - ./tests/test_json_string_matching.rb
203
- - ./tests/test_json_fixtures.rb
204
- - ./tests/test_json_unicode.rb
203
+ - ./tests/test_json.rb
205
204
  - ./tests/test_json_addition.rb
206
- - ./tests/test_json_generate.rb
207
205
  - ./tests/test_json_encoding.rb
206
+ - ./tests/test_json_fixtures.rb
207
+ - ./tests/test_json_generate.rb
208
208
  - ./tests/test_json_generic_object.rb
209
- - ./tests/test_json.rb
209
+ - ./tests/test_json_string_matching.rb
210
+ - ./tests/test_json_unicode.rb