summaryrefslogtreecommitdiff
path: root/louloulibs/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'louloulibs/xmpp')
-rw-r--r--louloulibs/xmpp/xmpp_stanza.cpp16
-rw-r--r--louloulibs/xmpp/xmpp_stanza.hpp2
2 files changed, 9 insertions, 9 deletions
diff --git a/louloulibs/xmpp/xmpp_stanza.cpp b/louloulibs/xmpp/xmpp_stanza.cpp
index f247436..407e631 100644
--- a/louloulibs/xmpp/xmpp_stanza.cpp
+++ b/louloulibs/xmpp/xmpp_stanza.cpp
@@ -84,6 +84,14 @@ std::string xml_unescape(const std::string& data)
return res;
}
+std::string sanitize(const std::string& data, const std::string& encoding)
+{
+ if (utils::is_valid_utf8(data.data()))
+ return xml_escape(utils::remove_invalid_xml_chars(data));
+ else
+ return xml_escape(utils::remove_invalid_xml_chars(utils::convert_to_utf8(data, encoding.data())));
+}
+
XmlNode::XmlNode(const std::string& name, XmlNode* parent):
parent(parent)
{
@@ -259,14 +267,6 @@ std::string& XmlNode::operator[](const std::string& name)
return this->attributes[name];
}
-std::string sanitize(const std::string& data)
-{
- if (utils::is_valid_utf8(data.data()))
- return xml_escape(utils::remove_invalid_xml_chars(data));
- else
- return xml_escape(utils::remove_invalid_xml_chars(utils::convert_to_utf8(data, "ISO-8859-1")));
-}
-
std::ostream& operator<<(std::ostream& os, const XmlNode& node)
{
return os << node.to_string();
diff --git a/louloulibs/xmpp/xmpp_stanza.hpp b/louloulibs/xmpp/xmpp_stanza.hpp
index bdc937f..77ab206 100644
--- a/louloulibs/xmpp/xmpp_stanza.hpp
+++ b/louloulibs/xmpp/xmpp_stanza.hpp
@@ -8,7 +8,7 @@
std::string xml_escape(const std::string& data);
std::string xml_unescape(const std::string& data);
-std::string sanitize(const std::string& data);
+std::string sanitize(const std::string& data, const std::string& encoding = "ISO-8859-1");
/**
* Represent an XML node. It has