Skip to content

Commit 39a5400

Browse files
committed
Fix xml output for invalid chars (cppcheck-opensource#6431)
1 parent a288d5e commit 39a5400

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

lib/errorlogger.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,7 @@ std::string ErrorLogger::ErrorMessage::fixInvalidChars(const std::string& raw)
242242
std::ostringstream es;
243243
// straight cast to (unsigned) doesn't work out.
244244
const unsigned uFrom = (unsigned char)*from;
245-
#if 0
246-
if (uFrom<0x20)
247-
es << "\\XXX";
248-
else
249-
#endif
250-
es << '\\' << std::setbase(8) << std::setw(3) << std::setfill('0') << uFrom;
245+
es << '\\' << std::setbase(8) << std::setw(3) << std::setfill('0') << uFrom;
251246
result += es.str();
252247
}
253248
++from;
@@ -271,7 +266,7 @@ std::string ErrorLogger::ErrorMessage::toXML(bool verbose, int version) const
271266
}
272267
printer.PushAttribute("id", _id.c_str());
273268
printer.PushAttribute("severity", (_severity == Severity::error ? "error" : "style"));
274-
printer.PushAttribute("msg", (verbose ? _verboseMessage : _shortMessage).c_str());
269+
printer.PushAttribute("msg", fixInvalidChars(verbose ? _verboseMessage : _shortMessage).c_str());
275270
printer.CloseElement(false);
276271
return printer.CStr();
277272
}

0 commit comments

Comments
 (0)