Mercurial > pidgin
changeset 31684:6e5d46ea82f9
merge of '8512af37c7822c68f1cf46a02cbca592f6c79468'
and 'dc05140f38c2811411a326665b3a2ebb1abeb51a'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 24 Jun 2011 06:54:33 +0000 |
parents | 3e98b34853ee (diff) 8c027bc27073 (current diff) |
children | 47c604efed32 |
files | ChangeLog |
diffstat | 6 files changed, 64 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jun 22 07:31:02 2011 +0000 +++ b/ChangeLog Fri Jun 24 06:54:33 2011 +0000 @@ -4,6 +4,7 @@ Gadu-Gadu: * Fixed searching for buddies in public directory. (Tomasz Wasilczyk) (#5242) + * Better status message handling. (Tomasz Wasilczyk) (#14314) version 2.9.0 (06/23/2011): Pidgin:
--- a/libpurple/protocols/gg/gg.c Wed Jun 22 07:31:02 2011 +0000 +++ b/libpurple/protocols/gg/gg.c Fri Jun 24 06:54:33 2011 +0000 @@ -1071,6 +1071,7 @@ { gchar *from; const char *st; + char *status_msg = NULL; ggp_update_buddy_avatar(gc, uin); @@ -1108,14 +1109,24 @@ break; } - purple_debug_info("gg", "st = %s\n", st); - //msg = charset_convert(descr, "CP1250", "UTF-8"); - if (descr == NULL) { + if (descr != NULL) { + status_msg = g_strdup(descr); + g_strstrip(status_msg); + if (status_msg[0] == '\0') { + g_free(status_msg); + status_msg = NULL; + } + } + + purple_debug_info("gg", "status of %u is %s [%s]\n", uin, st, + status_msg ? status_msg : ""); + if (status_msg == NULL) { purple_prpl_got_user_status(purple_connection_get_account(gc), - from, st, NULL); + from, st, NULL); } else { purple_prpl_got_user_status(purple_connection_get_account(gc), - from, st, "message", descr, NULL); + from, st, "message", status_msg, NULL); + g_free(status_msg); } g_free(from); } @@ -1945,23 +1956,18 @@ char *text; char *tmp; - status = purple_presence_get_active_status(purple_buddy_get_presence(b)); - + status = purple_presence_get_active_status( + purple_buddy_get_presence(b)); msg = purple_status_get_attr_string(status, "message"); - if (msg != NULL) { - tmp = purple_markup_strip_html(msg); - text = g_markup_escape_text(tmp, -1); - g_free(tmp); - - return text; - } else { - tmp = purple_utf8_salvage(purple_status_get_name(status)); - text = g_markup_escape_text(tmp, -1); - g_free(tmp); - - return text; - } + if (msg == NULL) + return NULL; + + tmp = purple_markup_strip_html(msg); + text = g_markup_escape_text(tmp, -1); + g_free(tmp); + + return text; } static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
--- a/libpurple/tests/Makefile.am Wed Jun 22 07:31:02 2011 +0000 +++ b/libpurple/tests/Makefile.am Fri Jun 24 06:54:33 2011 +0000 @@ -17,6 +17,7 @@ test_oscar_util.c \ test_yahoo_util.c \ test_util.c \ + test_xmlnode.c \ $(top_builddir)/libpurple/util.h check_libpurple_CFLAGS=\
--- a/libpurple/tests/check_libpurple.c Wed Jun 22 07:31:02 2011 +0000 +++ b/libpurple/tests/check_libpurple.c Fri Jun 24 06:54:33 2011 +0000 @@ -91,6 +91,7 @@ srunner_add_suite(sr, oscar_util_suite()); srunner_add_suite(sr, yahoo_util_suite()); srunner_add_suite(sr, util_suite()); + srunner_add_suite(sr, xmlnode_suite()); /* make this a libpurple "ui" */ purple_check_init();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/tests/test_xmlnode.c Fri Jun 24 06:54:33 2011 +0000 @@ -0,0 +1,34 @@ +#include <string.h> + +#include "tests.h" +#include "../xmlnode.h" + +/* + * If we really wanted to test the billion laughs attack we would + * need to have more than just 4 ha's. But as long as this shorter + * document fails to parse, the longer one should also fail to parse. + */ +START_TEST(test_xmlnode_billion_laughs_attack) +{ + const char *malicious_xml_doc = "<!DOCTYPE root [ <!ENTITY ha \"Ha !\"><!ENTITY ha2 \"&ha; &ha;\"><!ENTITY ha3 \"&ha2; &ha2;\"> ]><root>&ha3;</root>"; + + /* Uncomment this line if you want to see the error message given by + the parser for the above XML document */ + /* purple_debug_set_enabled(TRUE); */ + + fail_if(xmlnode_from_str(malicious_xml_doc, -1), + "xmlnode_from_str() returned an XML tree, but we didn't want it to"); +} +END_TEST + +Suite * +xmlnode_suite(void) +{ + Suite *s = suite_create("Utility Functions"); + + TCase *tc = tcase_create("xmlnode"); + tcase_add_test(tc, test_xmlnode_billion_laughs_attack); + suite_add_tcase(s, tc); + + return s; +}
--- a/libpurple/tests/tests.h Wed Jun 22 07:31:02 2011 +0000 +++ b/libpurple/tests/tests.h Fri Jun 24 06:54:33 2011 +0000 @@ -16,6 +16,7 @@ Suite * oscar_util_suite(void); Suite * yahoo_util_suite(void); Suite * util_suite(void); +Suite * xmlnode_suite(void); /* helper macros */ #define assert_int_equal(expected, actual) { \