From 5d05694920fccf63e08e42c1a7905fb7c8d722a6 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sun, 20 Jan 2019 15:58:51 +0100 Subject: [PATCH] json-rpc: Remove double-quoting on errors in JSON-RPC The use of `json_tok_full_len` and `json_tok_full` in addition to single quotes will result in double quoting, which is really weird. I opted to single quoting using `'` instead which does not need to be escaped. Signed-off-by: Christian Decker --- lightningd/jsonrpc.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index 7e8e8b3fa..3f6427ed9 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -353,8 +353,8 @@ static struct command_result *json_help(struct command *cmd, } return command_fail(cmd, JSONRPC2_METHOD_NOT_FOUND, "Unknown command '%.*s'", - json_tok_full_len(cmdtok), - json_tok_full(buffer, cmdtok)); + cmdtok->end - cmdtok->start, + buffer + cmdtok->start); } response = json_stream_success(cmd); @@ -584,12 +584,11 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[]) "Expected string for method"); } - c->json_cmd = find_cmd(jcon->ld->jsonrpc, jcon->buffer, method); - if (!c->json_cmd) { - return command_fail(c, JSONRPC2_METHOD_NOT_FOUND, - "Unknown command '%.*s'", - json_tok_full_len(method), - json_tok_full(jcon->buffer, method)); + c->json_cmd = find_cmd(jcon->ld->jsonrpc, jcon->buffer, method); + if (!c->json_cmd) { + return command_fail( + c, JSONRPC2_METHOD_NOT_FOUND, "Unknown command '%.*s'", + method->end - method->start, jcon->buffer + method->start); } if (c->json_cmd->deprecated && !deprecated_apis) { return command_fail(c, JSONRPC2_METHOD_NOT_FOUND,