summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Michaels-Ober <sferik@gmail.com>2012-10-05 09:11:36 -0700
committerErik Michaels-Ober <sferik@gmail.com>2012-10-05 09:11:51 -0700
commit9f43acbaff619d813b5a96b7e303b4876dbdf9b9 (patch)
tree4bfbbf8dc3e2f14efe8fda5e41c2f44e59dd4429
parent01a5165bee5c8cf199e37b3ccc90f1f824d41783 (diff)
downloadjson-9f43acbaff619d813b5a96b7e303b4876dbdf9b9.tar.gz
Increase default max_nesting to 100
See discussion at https://github.com/intridea/multi_json/pull/59.
-rw-r--r--ext/json/ext/generator/generator.c4
-rw-r--r--ext/json/ext/parser/parser.c6
-rw-r--r--java/src/json/ext/GeneratorState.java2
-rw-r--r--java/src/json/ext/Parser.java2
-rw-r--r--lib/json/common.rb4
-rw-r--r--lib/json/pure/generator.rb4
-rw-r--r--lib/json/pure/parser.rb6
-rw-r--r--tests/fixtures/fail18.json2
-rwxr-xr-xtests/test_json.rb22
-rwxr-xr-xtests/test_json_generate.rb6
10 files changed, 29 insertions, 29 deletions
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c
index 3cff87d..ad7dfe3 100644
--- a/ext/json/ext/generator/generator.c
+++ b/ext/json/ext/generator/generator.c
@@ -558,7 +558,7 @@ static VALUE cState_configure(VALUE self, VALUE opts)
state->object_nl_len = len;
}
tmp = ID2SYM(i_max_nesting);
- state->max_nesting = 19;
+ state->max_nesting = 100;
if (option_given_p(opts, tmp)) {
VALUE max_nesting = rb_hash_aref(opts, tmp);
if (RTEST(max_nesting)) {
@@ -908,7 +908,7 @@ static VALUE cState_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE opts;
GET_STATE(self);
- state->max_nesting = 19;
+ state->max_nesting = 100;
state->buffer_initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
rb_scan_args(argc, argv, "01", &opts);
if (!NIL_P(opts)) cState_configure(self, opts);
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
index c140fdb..8442d21 100644
--- a/ext/json/ext/parser/parser.c
+++ b/ext/json/ext/parser/parser.c
@@ -1618,7 +1618,7 @@ static VALUE convert_encoding(VALUE source)
* _opts_ can have the following keys:
* * *max_nesting*: The maximum depth of nesting allowed in the parsed data
* structures. Disable depth checking with :max_nesting => false|nil|0, it
- * defaults to 19.
+ * defaults to 100.
* * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
* defiance of RFC 4627 to be parsed by the Parser. This option defaults to
* false.
@@ -1655,7 +1655,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
json->max_nesting = 0;
}
} else {
- json->max_nesting = 19;
+ json->max_nesting = 100;
}
tmp = ID2SYM(i_allow_nan);
if (option_given_p(opts, tmp)) {
@@ -1709,7 +1709,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
}
}
} else {
- json->max_nesting = 19;
+ json->max_nesting = 100;
json->allow_nan = 0;
json->create_additions = 1;
json->create_id = rb_funcall(mJSON, i_create_id, 0);
diff --git a/java/src/json/ext/GeneratorState.java b/java/src/json/ext/GeneratorState.java
index 0584959..14d5431 100644
--- a/java/src/json/ext/GeneratorState.java
+++ b/java/src/json/ext/GeneratorState.java
@@ -62,7 +62,7 @@ public class GeneratorState extends RubyObject {
* <code>0</code> means disabled.
*/
private int maxNesting = DEFAULT_MAX_NESTING;
- static final int DEFAULT_MAX_NESTING = 19;
+ static final int DEFAULT_MAX_NESTING = 100;
/**
* Whether special float values (<code>NaN</code>, <code>Infinity</code>,
* <code>-Infinity</code>) are accepted.
diff --git a/java/src/json/ext/Parser.java b/java/src/json/ext/Parser.java
index 5ba13ad..49e5315 100644
--- a/java/src/json/ext/Parser.java
+++ b/java/src/json/ext/Parser.java
@@ -58,7 +58,7 @@ public class Parser extends RubyObject {
private RubyClass arrayClass;
private RubyHash match_string;
- private static final int DEFAULT_MAX_NESTING = 19;
+ private static final int DEFAULT_MAX_NESTING = 100;
private static final ByteList JSON_MINUS_INFINITY = new ByteList(ByteList.plain("-Infinity"));
// constant names in the JSON module containing those values
diff --git a/lib/json/common.rb b/lib/json/common.rb
index 3349501..03892d9 100644
--- a/lib/json/common.rb
+++ b/lib/json/common.rb
@@ -139,7 +139,7 @@ module JSON
# keys:
# * *max_nesting*: The maximum depth of nesting allowed in the parsed data
# structures. Disable depth checking with :max_nesting => false. It defaults
- # to 19.
+ # to 100.
# * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
# defiance of RFC 4627 to be parsed by the Parser. This option defaults
# to false.
@@ -199,7 +199,7 @@ module JSON
# encountered. This options defaults to false.
# * *max_nesting*: The maximum depth of nesting allowed in the data
# structures from which JSON is to be generated. Disable depth checking
- # with :max_nesting => false, it defaults to 19.
+ # with :max_nesting => false, it defaults to 100.
#
# See also the fast_generate for the fastest creation method with the least
# amount of sanity checks, and the pretty_generate method for some
diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb
index 3c81915..6916678 100644
--- a/lib/json/pure/generator.rb
+++ b/lib/json/pure/generator.rb
@@ -229,8 +229,8 @@ module JSON
@ascii_only = opts[:ascii_only] if opts.key?(:ascii_only)
@depth = opts[:depth] || 0
@quirks_mode = opts[:quirks_mode] if opts.key?(:quirks_mode)
- if !opts.key?(:max_nesting) # defaults to 19
- @max_nesting = 19
+ if !opts.key?(:max_nesting) # defaults to 100
+ @max_nesting = 100
elsif opts[:max_nesting]
@max_nesting = opts[:max_nesting]
else
diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb
index 84eb67f..cb249b2 100644
--- a/lib/json/pure/parser.rb
+++ b/lib/json/pure/parser.rb
@@ -56,7 +56,7 @@ module JSON
# keys:
# * *max_nesting*: The maximum depth of nesting allowed in the parsed data
# structures. Disable depth checking with :max_nesting => false|nil|0,
- # it defaults to 19.
+ # it defaults to 100.
# * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
# defiance of RFC 4627 to be parsed by the Parser. This option defaults
# to false.
@@ -76,8 +76,8 @@ module JSON
source = convert_encoding source
end
super source
- if !opts.key?(:max_nesting) # defaults to 19
- @max_nesting = 19
+ if !opts.key?(:max_nesting) # defaults to 100
+ @max_nesting = 100
elsif opts[:max_nesting]
@max_nesting = opts[:max_nesting]
else
diff --git a/tests/fixtures/fail18.json b/tests/fixtures/fail18.json
index e2d130c..ebc11eb 100644
--- a/tests/fixtures/fail18.json
+++ b/tests/fixtures/fail18.json
@@ -1 +1 @@
-[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]
+[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
diff --git a/tests/test_json.rb b/tests/test_json.rb
index 22cd5ee..5ebe5ec 100755
--- a/tests/test_json.rb
+++ b/tests/test_json.rb
@@ -446,12 +446,12 @@ EOT
assert_raises(JSON::NestingError) { JSON.parse '[[]]', :max_nesting => 1 }
assert_raises(JSON::NestingError) { JSON.parser.new('[[]]', :max_nesting => 1).parse }
assert_equal [[]], JSON.parse('[[]]', :max_nesting => 2)
- too_deep = '[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]'
+ too_deep = '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'
too_deep_ary = eval too_deep
assert_raises(JSON::NestingError) { JSON.parse too_deep }
assert_raises(JSON::NestingError) { JSON.parser.new(too_deep).parse }
- assert_raises(JSON::NestingError) { JSON.parse too_deep, :max_nesting => 19 }
- ok = JSON.parse too_deep, :max_nesting => 20
+ assert_raises(JSON::NestingError) { JSON.parse too_deep, :max_nesting => 100 }
+ ok = JSON.parse too_deep, :max_nesting => 101
assert_equal too_deep_ary, ok
ok = JSON.parse too_deep, :max_nesting => nil
assert_equal too_deep_ary, ok
@@ -462,8 +462,8 @@ EOT
assert_raises(JSON::NestingError) { JSON.generate [[]], :max_nesting => 1 }
assert_equal '[[]]', JSON.generate([[]], :max_nesting => 2)
assert_raises(JSON::NestingError) { JSON.generate too_deep_ary }
- assert_raises(JSON::NestingError) { JSON.generate too_deep_ary, :max_nesting => 19 }
- ok = JSON.generate too_deep_ary, :max_nesting => 20
+ assert_raises(JSON::NestingError) { JSON.generate too_deep_ary, :max_nesting => 100 }
+ ok = JSON.generate too_deep_ary, :max_nesting => 101
assert_equal too_deep, ok
ok = JSON.generate too_deep_ary, :max_nesting => nil
assert_equal too_deep, ok
@@ -494,18 +494,18 @@ EOT
end
def test_dump
- too_deep = '[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]'
+ too_deep = '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'
assert_equal too_deep, JSON.dump(eval(too_deep))
assert_kind_of String, Marshal.dump(eval(too_deep))
- assert_raises(ArgumentError) { JSON.dump(eval(too_deep), 19) }
- assert_raises(ArgumentError) { Marshal.dump(eval(too_deep), 19) }
- assert_equal too_deep, JSON.dump(eval(too_deep), 20)
- assert_kind_of String, Marshal.dump(eval(too_deep), 20)
+ assert_raises(ArgumentError) { JSON.dump(eval(too_deep), 100) }
+ assert_raises(ArgumentError) { Marshal.dump(eval(too_deep), 100) }
+ assert_equal too_deep, JSON.dump(eval(too_deep), 101)
+ assert_kind_of String, Marshal.dump(eval(too_deep), 101)
output = StringIO.new
JSON.dump(eval(too_deep), output)
assert_equal too_deep, output.string
output = StringIO.new
- JSON.dump(eval(too_deep), output, 20)
+ JSON.dump(eval(too_deep), output, 101)
assert_equal too_deep, output.string
end
diff --git a/tests/test_json_generate.rb b/tests/test_json_generate.rb
index 1c7ae34..a7975bf 100755
--- a/tests/test_json_generate.rb
+++ b/tests/test_json_generate.rb
@@ -130,7 +130,7 @@ EOT
:quirks_mode => false,
:depth => 0,
:indent => " ",
- :max_nesting => 19,
+ :max_nesting => 100,
:object_nl => "\n",
:space => " ",
:space_before => "",
@@ -147,7 +147,7 @@ EOT
:quirks_mode => false,
:depth => 0,
:indent => "",
- :max_nesting => 19,
+ :max_nesting => 100,
:object_nl => "",
:space => "",
:space_before => "",
@@ -200,7 +200,7 @@ EOT
s = JSON.state.new
assert_equal 0, s.depth
assert_raises(JSON::NestingError) { ary.to_json(s) }
- assert_equal 19, s.depth
+ assert_equal 100, s.depth
end
def test_buffer_initial_length