From 39a5400b7d4be4dc89d1df31515bf733b94cf0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 1 Feb 2016 18:53:46 +0100 Subject: [PATCH] Fix xml output for invalid chars (#6431) --- lib/errorlogger.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 013bfa5bc..e4cf4af92 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -242,12 +242,7 @@ std::string ErrorLogger::ErrorMessage::fixInvalidChars(const std::string& raw) std::ostringstream es; // straight cast to (unsigned) doesn't work out. const unsigned uFrom = (unsigned char)*from; -#if 0 - if (uFrom<0x20) - es << "\\XXX"; - else -#endif - es << '\\' << std::setbase(8) << std::setw(3) << std::setfill('0') << uFrom; + es << '\\' << std::setbase(8) << std::setw(3) << std::setfill('0') << uFrom; result += es.str(); } ++from; @@ -271,7 +266,7 @@ std::string ErrorLogger::ErrorMessage::toXML(bool verbose, int version) const } printer.PushAttribute("id", _id.c_str()); printer.PushAttribute("severity", (_severity == Severity::error ? "error" : "style")); - printer.PushAttribute("msg", (verbose ? _verboseMessage : _shortMessage).c_str()); + printer.PushAttribute("msg", fixInvalidChars(verbose ? _verboseMessage : _shortMessage).c_str()); printer.CloseElement(false); return printer.CStr(); }