fixed #403
This commit is contained in:
parent
0ffdb03aa3
commit
a7881754f5
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.utils.XmlHelper;
|
||||||
|
|
||||||
public class Element {
|
public class Element {
|
||||||
protected String name;
|
protected String name;
|
||||||
protected Hashtable<String, String> attributes = new Hashtable<String, String>();
|
protected Hashtable<String, String> attributes = new Hashtable<String, String>();
|
||||||
|
@ -116,7 +118,7 @@ public class Element {
|
||||||
startTag.setAtttributes(this.attributes);
|
startTag.setAtttributes(this.attributes);
|
||||||
elementOutput.append(startTag);
|
elementOutput.append(startTag);
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
elementOutput.append(encodeEntities(content));
|
elementOutput.append(XmlHelper.encodeEntities(content));
|
||||||
} else {
|
} else {
|
||||||
for (Element child : children) {
|
for (Element child : children) {
|
||||||
elementOutput.append(child.toString());
|
elementOutput.append(child.toString());
|
||||||
|
@ -132,15 +134,6 @@ public class Element {
|
||||||
return name;
|
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() {
|
public void clearChildren() {
|
||||||
this.children.clear();
|
this.children.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.utils.XmlHelper;
|
||||||
|
|
||||||
public class Tag {
|
public class Tag {
|
||||||
public static final int NO = -1;
|
public static final int NO = -1;
|
||||||
public static final int START = 0;
|
public static final int START = 0;
|
||||||
|
@ -85,7 +87,7 @@ public class Tag {
|
||||||
tagOutput.append(' ');
|
tagOutput.append(' ');
|
||||||
tagOutput.append(entry.getKey());
|
tagOutput.append(entry.getKey());
|
||||||
tagOutput.append("=\"");
|
tagOutput.append("=\"");
|
||||||
tagOutput.append(entry.getValue());
|
tagOutput.append(XmlHelper.encodeEntities(entry.getValue()));
|
||||||
tagOutput.append('"');
|
tagOutput.append('"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue