cli: remove \ in simple format.
What changed, and why it matters
This commit changes how the command-line tool 'lightning-cli' prints JSON strings in its simple human-readable output mode. Previously, backslashes used for escaping (like \" to show a quote, or \\ to show a backslash) were left in place, so users saw extra backslashes on screen. The patch now strips the backslash for any escape it does not explicitly handle (only \n newline and \t tab are still converted). This is a display/output formatting fix, not a change to how data is parsed or stored.
Treat as a low-risk UI/output formatting fix. Reviewers may want to verify that dropping the backslash for all unhandled escapes is the intended behavior, and consider whether a proper JSON unescape table (including \b, \f, \uXXXX, etc.) would be more correct. No urgent security action is indicated by the diff alone.
Security signals we found
Output formatting change in CLI display path
Incomplete JSON string unescaping (only \n, \t handled; other escapes have backslash dropped)
No input parsing or network protocol change
No memory management, bounds, or authorization change
Evidence from the diff
In cli/lightning-cli.c, the human_readable() function prints JSON primitive/string tokens. The original code only translated \n and \t, leaving other JSON escape sequences (e.g. ", \, \/) untouched, so the raw backslash was printed. The patch adds an unconditional i++ after detecting any backslash-plus-character pair, effectively consuming and discarding the backslash for unhandled escapes while still printing the following character. This makes output more readable but is a partial/incomplete unescaping implementation.
Changed components
cli/lightning-cli.chuman_readable() functionsimple format output of lightning-cliInspect captured patch +2 / −1
diff --git a/cli/lightning-cli.c b/cli/lightning-cli.c
index dee4c124..b1b2acd5 100644
--- a/cli/lightning-cli.c
+++ b/cli/lightning-cli.c
@@ -36,7 +36,7 @@ static size_t human_readable(const char *buffer, const jsmntok_t *t, char term)
case JSMN_PRIMITIVE:
case JSMN_STRING:
for (i = t->start; i < t->end; i++) {
- /* We only translate \n and \t. */
+ /* We only translate \n, \t and remove other \s. */
if (buffer[i] == '\\' && i + 1 < t->end) {
if (buffer[i+1] == 'n') {
fputc('\n', stdout);
@@ -47,6 +47,7 @@ static size_t human_readable(const char *buffer, const jsmntok_t *t, char term)
i++;
continue;
}
+ i++;
}
fputc(buffer[i], stdout);
}
Why this scored 26/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.