1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

Improve StringUtils.escapeForXml()

This commit is contained in:
Florian Schmaus 2016-01-13 15:04:01 +01:00
parent f2a748db9a
commit e6a9027cc6
11 changed files with 169 additions and 43 deletions

View file

@ -332,7 +332,7 @@ public class StreamInitiation extends IQ {
.append(getNamespace()).append("\" ");
if (getName() != null) {
buffer.append("name=\"").append(StringUtils.escapeForXML(getName())).append("\" ");
buffer.append("name=\"").append(StringUtils.escapeForXmlAttribute(getName())).append("\" ");
}
if (getSize() > 0) {
@ -350,7 +350,7 @@ public class StreamInitiation extends IQ {
if ((desc != null && desc.length() > 0) || isRanged) {
buffer.append('>');
if (getDesc() != null && desc.length() > 0) {
buffer.append("<desc>").append(StringUtils.escapeForXML(getDesc())).append("</desc>");
buffer.append("<desc>").append(StringUtils.escapeForXmlText(getDesc())).append("</desc>");
}
if (isRanged()) {
buffer.append("<range/>");

View file

@ -525,13 +525,13 @@ public class VCard extends IQ {
private void updateFN() {
StringBuilder sb = new StringBuilder();
if (firstName != null) {
sb.append(StringUtils.escapeForXML(firstName)).append(' ');
sb.append(StringUtils.escapeForXml(firstName)).append(' ');
}
if (middleName != null) {
sb.append(StringUtils.escapeForXML(middleName)).append(' ');
sb.append(StringUtils.escapeForXml(middleName)).append(' ');
}
if (lastName != null) {
sb.append(StringUtils.escapeForXML(lastName));
sb.append(StringUtils.escapeForXml(lastName));
}
setField("FN", sb.toString());
}

View file

@ -58,7 +58,7 @@ public class DataLayoutTest {
+ "<text>SectionText - &amp; \u00E9 \u00E1 </text>"
+ "</section>"
+ "<text>PageText - &amp; \u00E9 \u00E1 </text>"
+ "<section label='&lt;html&gt;Number of Persons by&lt;br/&gt; Nationality and Status&lt;/html&gt;'>"
+ "<section label='&lt;html>Number of Persons by&lt;br/> Nationality and Status&lt;/html>'>"
+ "<reportedref/>"
+ "</section>"
+ "<text>&lt;html&gt;&lt;font color=&apos;red&apos;&gt;&lt;em&gt;DO NOT DELAY&lt;/em&gt;&lt;/font&gt;&lt;br/&gt;supply further information&lt;/html&gt;</text>"

View file

@ -7,7 +7,7 @@
</section>
<text>PageText - &amp; é á </text>
<section
label='&lt;html&gt;Number of Persons by&lt;br/&gt; Nationality and Status&lt;/html&gt;'>
label='&lt;html>Number of Persons by&lt;br/> Nationality and Status&lt;/html>'>
<reportedref />
</section>
<text><![CDATA[<html><font color='red'><em>DO NOT DELAY</em></font><br/>supply further information</html>]]></text>