From 235408636362a8c21752a869a1f603315b0d9e19 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 22 Feb 2020 18:02:37 +0300 Subject: UTF-8-sanitize command logs --- bbot/worker/worker.cxx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index f25a287..eb2609d 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -16,6 +16,7 @@ #include #include +#include // to_utf8() #include #include @@ -138,14 +139,11 @@ run_cmd (tracer& t, result_status r (result_status::success); - // Log the diagnostics. Also print it to stderr at verbosity level 3 or - // higher. + // UTF-8-sanitize and log the diagnostics. Also print the raw diagnostics + // to stderr at verbosity level 3 or higher. // - auto add = [&log, &t] (const string& s, bool trace = true) + auto add = [&log, &t] (string&& s, bool trace = true) { - log += s; - log += '\n'; - if (verb >= 3) { if (trace) @@ -153,6 +151,11 @@ run_cmd (tracer& t, else text << s; } + + to_utf8 (s, '?'); + + log += s; + log += '\n'; }; { @@ -161,7 +164,6 @@ run_cmd (tracer& t, for (string l; is.peek () != ifdstream::traits_type::eof (); ) { getline (is, l); - add (l, false); // Match the log line with the warning-detecting regular expressions // until the first match. @@ -183,6 +185,8 @@ run_cmd (tracer& t, } } } + + add (move (l), false /* trace */); } } -- cgit v1.1