mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-01 17:58:29 +00:00
Added method to encode xml content.
This commit is contained in:
parent
252f06e1b4
commit
709afc9806
@ -36,7 +36,7 @@
|
||||
#include "pch.hpp"
|
||||
#include <core/xml/Writer.h>
|
||||
#include <core/xml/WriterNode.h>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
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("</"+node->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;
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,8 @@ class Writer : public WriterNode{
|
||||
|
||||
std::string sendBuffer;
|
||||
|
||||
static std::string EncodeSpecialCharacters(std::string xmlContent);
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user