Hello!
I’ve recently faced an issue of incorrect xml from UnparsedIQ. All my thoughts in one unit test:
import org.jivesoftware.smack.Smack;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.junit.Assert;
import org.junit.Test;
public class PacketParserUtilsTest {
@Test
public void unparsedIq() throws Exception {
System.out.println(Smack.getVersion()); // 4.4.2 (4.4.2 2021-03-25)
String control = "<iq " +
" xmlns='jabber:client'" +
" type='result'" +
">" +
" <unknown/>" +
"</iq>\"";
Stanza message = PacketParserUtils.parseStanza(control);
String xml = message.toXML().toString(); // <iq xmlns='jabber:client' type='result'><unknown xmlns='jabber:client'<unknown/></unknown></iq>
Assert.assertEquals("<iq xmlns='jabber:client' type='result'><unknown/></iq>", xml);
}
}
I think, that unparsed content should be escaped and put as content of IQ tag. For now, UnparsedIQ.toXml returns an XML that won’t be parsed because of errors in XML syntax.