Skip to content

Commit

Permalink
Escape special characters in C++ XML logger (#7867)
Browse files Browse the repository at this point in the history
This avoids OMEdit parser errors (hopefully also crashes) for bad messages,
e.g. containing "quoted text".
  • Loading branch information
rfranke committed Sep 6, 2021
1 parent d7ba190 commit b4f8972
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -9,6 +9,9 @@
#include <Core/Utils/extension/FactoryExport.h>
#include <Core/Utils/extension/logger.hpp>

#include <boost/property_tree/xml_parser.hpp>
using boost::property_tree::xml_parser::encode_char_entities;

Logger* Logger::_instance = NULL;

Logger::Logger(LogSettings settings, bool enabled)
Expand Down Expand Up @@ -139,7 +142,7 @@ void LoggerXML::writeInternal(std::string msg, LogCategory cat, LogLevel lvl,
if (ls != LS_END) {
_stream << "<message stream=\"" << getCategory(cat) << "\" "
<< "type=\"" << getLevel(lvl) << "\" "
<< "text=\"" << msg << "\"";
<< "text=\"" << encode_char_entities(msg) << "\"";
if (ls == LS_BEGIN)
_stream << " >" << std::endl;
else
Expand Down

0 comments on commit b4f8972

Please sign in to comment.