aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-09-01 13:51:49 +0200
committeriNPUTmice <daniel@gultsch.de>2014-09-01 13:51:49 +0200
commita7881754f5869860aac058d58838e5da72d3b40d (patch)
treec4f5256a5321c9f0ad6e126a2651201782931e5b /src/eu/siacs
parent0ffdb03aa3fb5840989f149e733c4d6cdf98c9ad (diff)
fixed #403
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/utils/XmlHelper.java12
-rw-r--r--src/eu/siacs/conversations/xml/Element.java13
-rw-r--r--src/eu/siacs/conversations/xml/Tag.java4
3 files changed, 18 insertions, 11 deletions
diff --git a/src/eu/siacs/conversations/utils/XmlHelper.java b/src/eu/siacs/conversations/utils/XmlHelper.java
new file mode 100644
index 00000000..4dee07cf
--- /dev/null
+++ b/src/eu/siacs/conversations/utils/XmlHelper.java
@@ -0,0 +1,12 @@
+package eu.siacs.conversations.utils;
+
+public class XmlHelper {
+ public static String encodeEntities(String content) {
+ content = content.replace("&", "&amp;");
+ content = content.replace("<", "&lt;");
+ content = content.replace(">", "&gt;");
+ content = content.replace("\"", "&quot;");
+ content = content.replace("'", "&apos;");
+ return content;
+ }
+}
diff --git a/src/eu/siacs/conversations/xml/Element.java b/src/eu/siacs/conversations/xml/Element.java
index a09946c2..4e11ee2c 100644
--- a/src/eu/siacs/conversations/xml/Element.java
+++ b/src/eu/siacs/conversations/xml/Element.java
@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
+import eu.siacs.conversations.utils.XmlHelper;
+
public class Element {
protected String name;
protected Hashtable<String, String> attributes = new Hashtable<String, String>();
@@ -116,7 +118,7 @@ public class Element {
startTag.setAtttributes(this.attributes);
elementOutput.append(startTag);
if (content != null) {
- elementOutput.append(encodeEntities(content));
+ elementOutput.append(XmlHelper.encodeEntities(content));
} else {
for (Element child : children) {
elementOutput.append(child.toString());
@@ -132,15 +134,6 @@ public class Element {
return name;
}
- private String encodeEntities(String content) {
- content = content.replace("&", "&amp;");
- content = content.replace("<", "&lt;");
- content = content.replace(">", "&gt;");
- content = content.replace("\"", "&quot;");
- content = content.replace("'", "&apos;");
- return content;
- }
-
public void clearChildren() {
this.children.clear();
}
diff --git a/src/eu/siacs/conversations/xml/Tag.java b/src/eu/siacs/conversations/xml/Tag.java
index 2b393397..b9ef979f 100644
--- a/src/eu/siacs/conversations/xml/Tag.java
+++ b/src/eu/siacs/conversations/xml/Tag.java
@@ -5,6 +5,8 @@ import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
+import eu.siacs.conversations.utils.XmlHelper;
+
public class Tag {
public static final int NO = -1;
public static final int START = 0;
@@ -85,7 +87,7 @@ public class Tag {
tagOutput.append(' ');
tagOutput.append(entry.getKey());
tagOutput.append("=\"");
- tagOutput.append(entry.getValue());
+ tagOutput.append(XmlHelper.encodeEntities(entry.getValue()));
tagOutput.append('"');
}
}