From 7905307d5f75a2ddba7163b313ec53bc2469d810 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Sat, 22 May 2004 22:53:21 +0000 Subject: [PATCH] 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 --- source/org/jivesoftware/smack/packet/IQ.java | 6 ++++-- source/org/jivesoftware/smack/packet/Message.java | 4 ++-- source/org/jivesoftware/smack/packet/Presence.java | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/org/jivesoftware/smack/packet/IQ.java b/source/org/jivesoftware/smack/packet/IQ.java index 0a28c952a..0207643ec 100644 --- a/source/org/jivesoftware/smack/packet/IQ.java +++ b/source/org/jivesoftware/smack/packet/IQ.java @@ -52,6 +52,8 @@ 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 * on the server, including authentication, roster operations, and creating @@ -103,10 +105,10 @@ public abstract class IQ extends Packet { buf.append("id=\"" + getPacketID() + "\" "); } if (getTo() != null) { - buf.append("to=\"").append(getTo()).append("\" "); + buf.append("to=\"").append(StringUtils.escapeForXML(getTo())).append("\" "); } if (getFrom() != null) { - buf.append("from=\"").append(getFrom()).append("\" "); + buf.append("from=\"").append(StringUtils.escapeForXML(getFrom())).append("\" "); } if (type == null) { buf.append("type=\"get\">"); diff --git a/source/org/jivesoftware/smack/packet/Message.java b/source/org/jivesoftware/smack/packet/Message.java index 4e8b7acb2..f29d0fc08 100644 --- a/source/org/jivesoftware/smack/packet/Message.java +++ b/source/org/jivesoftware/smack/packet/Message.java @@ -203,10 +203,10 @@ public class Message extends Packet { buf.append(" id=\"").append(getPacketID()).append("\""); } if (getTo() != null) { - buf.append(" to=\"").append(getTo()).append("\""); + buf.append(" to=\"").append(StringUtils.escapeForXML(getTo())).append("\""); } if (getFrom() != null) { - buf.append(" from=\"").append(getFrom()).append("\""); + buf.append(" from=\"").append(StringUtils.escapeForXML(getFrom())).append("\""); } if (type != Type.NORMAL) { buf.append(" type=\"").append(type).append("\""); diff --git a/source/org/jivesoftware/smack/packet/Presence.java b/source/org/jivesoftware/smack/packet/Presence.java index a8ca9970f..0de63d21e 100644 --- a/source/org/jivesoftware/smack/packet/Presence.java +++ b/source/org/jivesoftware/smack/packet/Presence.java @@ -52,6 +52,8 @@ 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 * the following values: @@ -199,10 +201,10 @@ public class Presence extends Packet { buf.append(" id=\"").append(getPacketID()).append("\""); } if (getTo() != null) { - buf.append(" to=\"").append(getTo()).append("\""); + buf.append(" to=\"").append(StringUtils.escapeForXML(getTo())).append("\""); } if (getFrom() != null) { - buf.append(" from=\"").append(getFrom()).append("\""); + buf.append(" from=\"").append(StringUtils.escapeForXML(getFrom())).append("\""); } if (type != Type.AVAILABLE) { buf.append(" type=\"").append(type).append("\"");