1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-09 20:41:07 +01:00

Introduce and use XmlStringBuilder.text()

Smack currently does unnecessary escaping of XML text, where it
escapes e.g. '"' to '"'. This bloats the stanza size, especially
if JSON payloads are involved.

Fixes SMACK-892 (although there are probably still places where
XmlStringBuilder.escape() is used when XmlStringBuild.text() could
have been used).
This commit is contained in:
Florian Schmaus 2020-09-17 12:31:35 +02:00
parent 9e9d30074c
commit b7824f008d
6 changed files with 29 additions and 7 deletions

View file

@ -206,4 +206,17 @@ public class MessageTest {
assertXmlSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
/**
* Tests that only required characters are XML escaped in body.
*
* @see <a href="https://issues.igniterealtime.org/browse/SMACK-892">SMACK-892</a>
*/
@Test
public void escapeInBodyTest() {
String theFive = "\"'<>&";
Message.Body body = new Message.Body(null, theFive);
assertEquals("<body xmlns='jabber:client'>\"'&lt;>&amp;</body>", body.toXML().toString());
}
}