1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-06-16 08:34:50 +02:00

Escapes invalid charactes of the "to" and "from" fields in #toXML. SMACK-135

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2315 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2004-05-22 22:53:21 +00:00 committed by gdombiak
parent 5fdc96acab
commit 7905307d5f
3 changed files with 10 additions and 6 deletions

View file

@ -52,6 +52,8 @@
package org.jivesoftware.smack.packet; package org.jivesoftware.smack.packet;
import org.jivesoftware.smack.util.StringUtils;
/** /**
* The base IQ (Info/Query) packet. IQ packets are used to get and set information * The base IQ (Info/Query) packet. IQ packets are used to get and set information
* on the server, including authentication, roster operations, and creating * on the server, including authentication, roster operations, and creating
@ -103,10 +105,10 @@ public abstract class IQ extends Packet {
buf.append("id=\"" + getPacketID() + "\" "); buf.append("id=\"" + getPacketID() + "\" ");
} }
if (getTo() != null) { if (getTo() != null) {
buf.append("to=\"").append(getTo()).append("\" "); buf.append("to=\"").append(StringUtils.escapeForXML(getTo())).append("\" ");
} }
if (getFrom() != null) { if (getFrom() != null) {
buf.append("from=\"").append(getFrom()).append("\" "); buf.append("from=\"").append(StringUtils.escapeForXML(getFrom())).append("\" ");
} }
if (type == null) { if (type == null) {
buf.append("type=\"get\">"); buf.append("type=\"get\">");

View file

@ -203,10 +203,10 @@ public class Message extends Packet {
buf.append(" id=\"").append(getPacketID()).append("\""); buf.append(" id=\"").append(getPacketID()).append("\"");
} }
if (getTo() != null) { if (getTo() != null) {
buf.append(" to=\"").append(getTo()).append("\""); buf.append(" to=\"").append(StringUtils.escapeForXML(getTo())).append("\"");
} }
if (getFrom() != null) { if (getFrom() != null) {
buf.append(" from=\"").append(getFrom()).append("\""); buf.append(" from=\"").append(StringUtils.escapeForXML(getFrom())).append("\"");
} }
if (type != Type.NORMAL) { if (type != Type.NORMAL) {
buf.append(" type=\"").append(type).append("\""); buf.append(" type=\"").append(type).append("\"");

View file

@ -52,6 +52,8 @@
package org.jivesoftware.smack.packet; package org.jivesoftware.smack.packet;
import org.jivesoftware.smack.util.StringUtils;
/** /**
* Represents XMPP presence packets. Every presence packet has a type, which is one of * Represents XMPP presence packets. Every presence packet has a type, which is one of
* the following values: * the following values:
@ -199,10 +201,10 @@ public class Presence extends Packet {
buf.append(" id=\"").append(getPacketID()).append("\""); buf.append(" id=\"").append(getPacketID()).append("\"");
} }
if (getTo() != null) { if (getTo() != null) {
buf.append(" to=\"").append(getTo()).append("\""); buf.append(" to=\"").append(StringUtils.escapeForXML(getTo())).append("\"");
} }
if (getFrom() != null) { if (getFrom() != null) {
buf.append(" from=\"").append(getFrom()).append("\""); buf.append(" from=\"").append(StringUtils.escapeForXML(getFrom())).append("\"");
} }
if (type != Type.AVAILABLE) { if (type != Type.AVAILABLE) {
buf.append(" type=\"").append(type).append("\""); buf.append(" type=\"").append(type).append("\"");