From d78587c18de0f205047fd6fa6018df059db35a82 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 25 Oct 2024 18:13:52 -0700 Subject: [PATCH] pipeline: escape log command line --- src/pipeline.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pipeline.cc b/src/pipeline.cc index 22debd17..cc954b90 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -364,8 +364,14 @@ bool indexer_Parse(SemaManager *completion, WorkingFiles *wfiles, Project *proje msg += " error:" + std::to_string(n_errs) + ' ' + first_error; if (LOG_V_ENABLED(1)) { msg += "\n "; - for (const char *arg : entry.args) - (msg += ' ') += arg; + for (const char *arg_c : entry.args) { + msg += ' '; + std::string_view arg(arg_c); + if (arg.find_first_of("\"()<>") != std::string::npos) + ((msg += "'") += arg) += "'"; + else + msg += arg; + } } LOG_S(INFO) << std::string_view(msg.data(), msg.size()); }