1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 22:32:06 +01:00

Escape nickname in Nick.toXML()

This commit is contained in:
Florian Schmaus 2018-10-21 08:57:45 +02:00
parent 00ce194109
commit c053f5a41b

View file

@ -20,6 +20,7 @@ import java.io.IOException;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
@ -87,15 +88,14 @@ public class Nick implements ExtensionElement {
* @see org.jivesoftware.smack.packet.PacketExtension#toXML() * @see org.jivesoftware.smack.packet.PacketExtension#toXML()
*/ */
@Override @Override
public String toXML(String enclosingNamespace) { public XmlStringBuilder toXML(String enclosingNamespace) {
final StringBuilder buf = new StringBuilder(); XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
xml.rightAngleBracket();
buf.append('<').append(ELEMENT_NAME).append(" xmlns=\"").append( xml.escape(getName());
NAMESPACE).append("\">");
buf.append(getName());
buf.append("</").append(ELEMENT_NAME).append('>');
return buf.toString(); xml.closeElement(this);
return xml;
} }
public static class Provider extends ExtensionElementProvider<Nick> { public static class Provider extends ExtensionElementProvider<Nick> {