summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer/XML/XMLElement.cpp')
-rw-r--r--Swiften/Serializer/XML/XMLElement.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/Swiften/Serializer/XML/XMLElement.cpp b/Swiften/Serializer/XML/XMLElement.cpp
index f2397ca..7515061 100644
--- a/Swiften/Serializer/XML/XMLElement.cpp
+++ b/Swiften/Serializer/XML/XMLElement.cpp
@@ -39,14 +39,17 @@ std::string XMLElement::serialize() {
39 return result; 39 return result;
40} 40}
41 41
42std::string XMLElement::escapeAttributeValue(std::string value) {
43 String::replaceAll(value, '&', "&");
44 String::replaceAll(value, '<', "&lt;");
45 String::replaceAll(value, '>', "&gt;");
46 String::replaceAll(value, '\'', "&apos;");
47 String::replaceAll(value, '"', "&quot;");
48 return value;
49}
50
42void XMLElement::setAttribute(const std::string& attribute, const std::string& value) { 51void XMLElement::setAttribute(const std::string& attribute, const std::string& value) {
43 std::string escapedValue(value); 52 attributes_[attribute] = escapeAttributeValue(value);
44 String::replaceAll(escapedValue, '&', "&amp;");
45 String::replaceAll(escapedValue, '<', "&lt;");
46 String::replaceAll(escapedValue, '>', "&gt;");
47 String::replaceAll(escapedValue, '\'', "&apos;");
48 String::replaceAll(escapedValue, '"', "&quot;");
49 attributes_[attribute] = escapedValue;
50} 53}
51 54
52void XMLElement::addNode(std::shared_ptr<XMLNode> node) { 55void XMLElement::addNode(std::shared_ptr<XMLNode> node) {