From 88a935d8d1c63b18b240ad1a4d8196fc84f6b4c3 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 26 Mar 2019 17:45:25 +0100 Subject: [PATCH] Escape arguments in stacktraces See #5434. --- src/parser.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parser.cpp b/src/parser.cpp index a920b477d..15871ed03 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -387,7 +387,13 @@ void parser_t::stack_trace_internal(size_t block_idx, wcstring *buff) const { for (i = 1; process->argv(i); i++) { if (i > 1) tmp.push_back(L' '); - tmp.append(process->argv(i)); + // We can't quote the arguments because we print this in quotes. + // As a special-case, add the empty argument as "". + if (process->argv(i)[0]) { + tmp.append(escape_string(process->argv(i), ESCAPE_ALL | ESCAPE_NO_QUOTED)); + } else { + tmp.append(L"\"\""); + } } // TODO: Escape these. append_format(*buff, _(L" with arguments '%ls'\n"), tmp.c_str());