diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-09-01 13:51:49 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-09-01 14:03:21 +0200 |
commit | d42ea45b1c7356793aa55edf55baeaaf4cd3398f (patch) | |
tree | cff01f1eb743c873e930d28095de9d14322fba25 /src/eu/siacs/conversations | |
parent | 9ad5c6925d103f5d0a030bd7af76cb8d15551189 (diff) |
fixed #403
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/utils/XmlHelper.java | 12 | ||||
-rw-r--r-- | src/eu/siacs/conversations/xml/Element.java | 13 | ||||
-rw-r--r-- | src/eu/siacs/conversations/xml/Tag.java | 4 |
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("&", "&"); + content = content.replace("<", "<"); + content = content.replace(">", ">"); + content = content.replace("\"", """); + content = content.replace("'", "'"); + return content; + } +} diff --git a/src/eu/siacs/conversations/xml/Element.java b/src/eu/siacs/conversations/xml/Element.java index 3d22ba6a..cc21a780 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("&", "&"); - content = content.replace("<", "<"); - content = content.replace(">", ">"); - content = content.replace("\"", """); - content = content.replace("'", "'"); - 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 2d5ffdbc..a9eecad6 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; @@ -84,7 +86,7 @@ public class Tag { tagOutput.append(' '); tagOutput.append(entry.getKey()); tagOutput.append("=\""); - tagOutput.append(entry.getValue()); + tagOutput.append(XmlHelper.encodeEntities(entry.getValue())); tagOutput.append('"'); } } |