summaryrefslogtreecommitdiff
path: root/louloulibs/xmpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-12-28 21:25:48 +0100
committerFlorent Le Coz <louiz@louiz.org>2016-01-04 13:47:26 +0100
commit79cdf170d2ab6c5378cfbf61d5c8888a4c666190 (patch)
tree931a5d2b6b3754d43d610fb28d2e452b55ee54d4 /louloulibs/xmpp
parentb0c3aa0be960443b3959d0026f29f1dba18a08c3 (diff)
downloadbiboumi-79cdf170d2ab6c5378cfbf61d5c8888a4c666190.tar.gz
biboumi-79cdf170d2ab6c5378cfbf61d5c8888a4c666190.tar.bz2
biboumi-79cdf170d2ab6c5378cfbf61d5c8888a4c666190.tar.xz
biboumi-79cdf170d2ab6c5378cfbf61d5c8888a4c666190.zip
Use the configured encoding value when decoding received messages
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