mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 06:44:24 +01:00
common/json_escaped: new type which explicitly notes a string is already JSON.
Trivial to use as a string, but it still means you should be careful around it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "../json.c"
|
||||
#include "../json_escaped.c"
|
||||
#include <stdio.h>
|
||||
|
||||
/* AUTOGENERATED MOCKS START */
|
||||
@@ -85,12 +86,14 @@ static void test_json_escape(void)
|
||||
for (i = 1; i < 256; i++) {
|
||||
char badstr[2];
|
||||
struct json_result *result = new_json_result(NULL);
|
||||
struct json_escaped *esc;
|
||||
|
||||
badstr[0] = i;
|
||||
badstr[1] = 0;
|
||||
|
||||
json_object_start(result, NULL);
|
||||
json_add_string_escape(result, "x", badstr);
|
||||
esc = json_escape(NULL, badstr);
|
||||
json_add_escaped_string(result, "x", take(esc));
|
||||
json_object_end(result);
|
||||
|
||||
str = json_result_string(result);
|
||||
@@ -114,4 +117,6 @@ int main(void)
|
||||
test_json_tok_bitcoin_amount();
|
||||
test_json_filter();
|
||||
test_json_escape();
|
||||
assert(!taken_any());
|
||||
take_cleanup();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user