mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-10-31 17:25:58 +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:
parent
b34152e9f5
commit
469ff4d487
2 changed files with 26 additions and 1 deletions
|
@ -200,7 +200,7 @@ public class RosterPacket extends IQ {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<item jid=\"").append(user).append("\"");
|
||||
if (name != null) {
|
||||
buf.append(" name=\"").append(name).append("\"");
|
||||
buf.append(" name=\"").append(StringUtils.escapeForXML(name)).append("\"");
|
||||
}
|
||||
if (itemType != null) {
|
||||
buf.append(" subscription=\"").append(itemType).append("\"");
|
||||
|
|
|
@ -590,6 +590,31 @@ public class RosterTest extends SmackTestCase {
|
|||
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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue