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

Roster item nickname is now escaped for XML. SMACK-164

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@4882 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2006-08-10 21:35:08 +00:00 committed by gato
parent b34152e9f5
commit 469ff4d487
2 changed files with 26 additions and 1 deletions

View file

@ -200,7 +200,7 @@ public class RosterPacket extends IQ {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<item jid=\"").append(user).append("\""); buf.append("<item jid=\"").append(user).append("\"");
if (name != null) { if (name != null) {
buf.append(" name=\"").append(name).append("\""); buf.append(" name=\"").append(StringUtils.escapeForXML(name)).append("\"");
} }
if (itemType != null) { if (itemType != null) {
buf.append(" subscription=\"").append(itemType).append("\""); buf.append(" subscription=\"").append(itemType).append("\"");

View file

@ -590,6 +590,31 @@ public class RosterTest extends SmackTestCase {
assertNull("Presence found for removed contact", presence); assertNull("Presence found for removed contact", presence);
} }
/**
* Tests that the server and Smack are able to handle nicknames that include
* < > characters.
*/
public void testNotCommonNickname() throws Exception {
// Add a new roster entry
Roster roster = getConnection(0).getRoster();
roster.createEntry(getBareJID(1), "Thiago <12001200>", null);
Thread.sleep(500);
assertEquals("Created entry was never received", 1, roster.getEntryCount());
// Create another connection for the same user of connection 0
XMPPConnection conn2 = new XMPPConnection(getServiceName());
conn2.login(getUsername(0), getUsername(0), "Home");
// Retrieve roster and verify that new contact is there and nickname is correct
Roster roster2 = conn2.getRoster();
assertEquals("Created entry was never received", 1, roster2.getEntryCount());
RosterEntry entry = roster2.getEntry(getBareJID(1));
assertNotNull("New entry was not returned from the server", entry);
assertEquals("Roster item name is incorrect", "Thiago <12001200>", entry.getName());
}
/** /**
* Clean up all the entries in the roster * Clean up all the entries in the roster
*/ */