diff --git a/src/core/xml/Writer.cpp b/src/core/xml/Writer.cpp index c2adcf19e..6fab0e418 100644 --- a/src/core/xml/Writer.cpp +++ b/src/core/xml/Writer.cpp @@ -36,7 +36,7 @@ #include "pch.hpp" #include #include - +#include using namespace musik::core::xml; @@ -154,7 +154,7 @@ void Writer::Send(){ if(node!=this->node){ // Do not send root node // Send the content and end tag - sendBuffer.append(node->content); + sendBuffer.append(Writer::EncodeSpecialCharacters(node->content)); sendBuffer.append("name+">"); } @@ -184,4 +184,12 @@ void Writer::Send(){ } +std::string Writer::EncodeSpecialCharacters(std::string xmlContent){ + boost::algorithm::replace_all(xmlContent,"<","<"); + boost::algorithm::replace_all(xmlContent,">",">"); + boost::algorithm::replace_all(xmlContent,"&","&"); + boost::algorithm::replace_all(xmlContent,"\"","""); + boost::algorithm::replace_all(xmlContent,"'","'"); + return xmlContent; +} diff --git a/src/core/xml/Writer.h b/src/core/xml/Writer.h index 245a7d3e1..7134f851b 100644 --- a/src/core/xml/Writer.h +++ b/src/core/xml/Writer.h @@ -75,6 +75,8 @@ class Writer : public WriterNode{ std::string sendBuffer; + static std::string EncodeSpecialCharacters(std::string xmlContent); + }; //////////////////////////////////////////////////////////////////////////////