Permalink
Browse files

Increases MAX_NESTING of json objects/arrays to 2048.

Fixes #75
1 parent dd9eed2 commit e410fc7c33208a09a1fb35e0ed7ba65321101996 @kgabis committed May 8, 2017
Showing with 4 additions and 11 deletions.
  1. +1 −1 parson.c
  2. +2 −9 tests.c
  3. +1 −1 tests/test_1_2.txt
View
@@ -42,7 +42,7 @@
#define STARTING_CAPACITY 15
#define ARRAY_MAX_CAPACITY 122880 /* 15*(2^13) */
#define OBJECT_MAX_CAPACITY 960 /* 15*(2^6) */
-#define MAX_NESTING 19
+#define MAX_NESTING 2048
#define DOUBLE_SERIALIZATION_FORMAT "%f"
#define SIZEOF_TOKEN(a) (sizeof(a) - 1)
View
11 tests.c
@@ -86,9 +86,7 @@ void test_suite_1(void) {
TEST(json_value_equals(json_parse_string(json_serialize_to_string_pretty(val)), val));
if (val) { json_value_free(val); }
- TEST((val = json_parse_file("tests/test_1_2.txt")) != NULL);
- TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val));
- TEST(json_value_equals(json_parse_string(json_serialize_to_string_pretty(val)), val));
+ TEST((val = json_parse_file("tests/test_1_2.txt")) == NULL); /* Over 2048 levels of nesting */
if (val) { json_value_free(val); }
TEST((val = json_parse_file("tests/test_1_3.txt")) != NULL);
@@ -101,9 +99,7 @@ void test_suite_1(void) {
TEST(json_value_equals(json_parse_string(json_serialize_to_string_pretty(val)), val));
if (val) { json_value_free(val); }
- TEST((val = json_parse_file_with_comments("tests/test_1_2.txt")) != NULL);
- TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val));
- TEST(json_value_equals(json_parse_string(json_serialize_to_string_pretty(val)), val));
+ TEST((val = json_parse_file_with_comments("tests/test_1_2.txt")) == NULL); /* Over 2048 levels of nesting */
if (val) { json_value_free(val); }
TEST((val = json_parse_file_with_comments("tests/test_1_3.txt")) != NULL);
@@ -238,8 +234,6 @@ void test_suite_2_with_comments(void) {
}
void test_suite_3(void) {
- char nested_20x[] = "[[[[[[[[[[[[[[[[[[[[\"hi\"]]]]]]]]]]]]]]]]]]]]";
-
puts("Testing valid strings:");
TEST(json_parse_string("{\"lorem\":\"ipsum\"}") != NULL);
TEST(json_parse_string("[\"lorem\"]") != NULL);
@@ -281,7 +275,6 @@ void test_suite_3(void) {
TEST(json_parse_string("[\"\n\"]") == NULL); /* control character */
TEST(json_parse_string("[\"\f\"]") == NULL); /* control character */
TEST(json_parse_string("[\"\r\"]") == NULL); /* control character */
- TEST(json_parse_string(nested_20x) == NULL); /* too deep */
TEST(json_parse_string("[0x2]") == NULL); /* hex */
TEST(json_parse_string("[0X2]") == NULL); /* HEX */
TEST(json_parse_string("[07]") == NULL); /* octals */
View
@@ -1 +1 @@
-[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
+[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[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