Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/presence.c @ 25882:54dcfe059dd4
*** Plucked rev 3993504a (darkrain42@pidgin.im):
Don't crash when a broken server sends us an occupant's presence with an
empty resource. Closes #8361.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 02 May 2009 21:08:59 +0000 |
parents | bba38f03085d |
children | 3c1022fd4893 |
comparison
equal
deleted
inserted
replaced
25881:13d8b6c6ae42 | 25882:54dcfe059dd4 |
---|---|
599 | 599 |
600 | 600 |
601 if(type && !strcmp(type, "unavailable")) { | 601 if(type && !strcmp(type, "unavailable")) { |
602 gboolean nick_change = FALSE; | 602 gboolean nick_change = FALSE; |
603 | 603 |
604 /* If we haven't joined the chat yet, we don't care that someone | 604 /* If the chat nick is invalid, we haven't yet joined, or we've |
605 * left, or it was us leaving after we closed the chat */ | 605 * already left (it was probably us leaving after we closed the |
606 if (!chat->conv || chat->left) { | 606 * chat), we don't care. |
607 */ | |
608 if (!jid->resource || !chat->conv || chat->left) { | |
607 if (chat->left && | 609 if (chat->left && |
608 jid->resource && chat->handle && !strcmp(jid->resource, chat->handle)) | 610 jid->resource && chat->handle && !strcmp(jid->resource, chat->handle)) |
609 jabber_chat_destroy(chat); | 611 jabber_chat_destroy(chat); |
610 jabber_id_free(jid); | 612 jabber_id_free(jid); |
611 g_free(status); | 613 g_free(status); |
662 status); | 664 status); |
663 jabber_chat_remove_handle(chat, jid->resource); | 665 jabber_chat_remove_handle(chat, jid->resource); |
664 } | 666 } |
665 } | 667 } |
666 } else { | 668 } else { |
669 /* | |
670 * XEP-0045 mandates the presence to include a resource (which is | |
671 * treated as the chat nick). Some non-compliant servers allow | |
672 * joining without a nick. | |
673 */ | |
674 if (!jid->resource) { | |
675 jabber_id_free(jid); | |
676 g_free(avatar_hash); | |
677 g_free(nickname); | |
678 g_free(status); | |
679 return; | |
680 } | |
681 | |
667 if(!chat->conv) { | 682 if(!chat->conv) { |
668 chat->id = i++; | 683 chat->id = i++; |
669 chat->muc = muc; | 684 chat->muc = muc; |
670 chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid); | 685 chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid); |
671 purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle); | 686 purple_conv_chat_set_nick(PURPLE_CONV_CHAT(chat->conv), chat->handle); |