Not parsing strings in json_value_init_string and *{set,dotset,replace,append}_string functions.

pull/29/head
Krzysztof Gabis 9 years ago
parent 0d5ac45286
commit 4a4cf7d795
  1. 8
      parson.c
  2. 5
      tests.c
  3. 3
      tests/test_5.txt

@ -972,13 +972,13 @@ JSON_Value * json_value_init_array(void) {
}
JSON_Value * json_value_init_string(const char *string) {
char *processed_copy = NULL;
char *copy = NULL;
if (string == NULL)
return NULL;
processed_copy = process_string(string, strlen(string));
if (processed_copy == NULL)
copy = parson_strdup(string);
if (copy == NULL)
return NULL;
return json_value_init_string_no_copy(processed_copy);
return json_value_init_string_no_copy(copy);
}
JSON_Value * json_value_init_number(double number) {

@ -264,9 +264,10 @@ void test_suite_5(void) {
TEST(json_object_dotset_string(obj, "favorites.sport", "running") == JSONSuccess);
TEST(json_object_dotset_string(obj, "favorites.fruit", "apple") == JSONSuccess);
TEST(json_object_dotremove(obj, "favorites.fruit") == JSONSuccess);
TEST(json_object_set_string(obj, "utf string", "\\u006corem\\u0020ipsum") == JSONSuccess);
TEST(json_object_set_string(obj, "utf string", "lorem ipsum") == JSONSuccess);
TEST(json_object_set_string(obj, "utf-8 string", "あいうえお") == JSONSuccess);
TEST(json_object_set_string(obj, "surrogate string", "lorem\\uD834\\uDD1Eipsum\\uD834\\uDF67lorem") == JSONSuccess);
TEST(json_object_set_string(obj, "surrogate string", "lorem𝄞ipsum𝍧lorem") == JSONSuccess);
TEST(json_object_set_string(obj, "windows path", "C:\\Windows\\Path") == JSONSuccess);
TEST(json_value_equals(val_from_file, val));
TEST(json_object_set_string(obj, NULL, "") == JSONFailure);

@ -10,5 +10,6 @@
},
"utf string" : "\u006corem\u0020ipsum",
"utf-8 string": "あいうえお",
"surrogate string": "lorem\uD834\uDD1Eipsum\uD834\uDF67lorem"
"surrogate string": "lorem\uD834\uDD1Eipsum\uD834\uDF67lorem",
"windows path": "C:\\Windows\\Path"
}
Loading…
Cancel
Save