# HG changeset patch # User Yoshiki Yazawa # Date 1180941758 0 # Node ID 67ad619bd97f47ad12d57215f9462b169e9d59a3 # Parent 794abbe3e14ea3558e372d4eb900e4512ce31b4b# Parent 295777a9e2a4ad5fab04d6956220037264ec722f propagate from branch 'im.pidgin.pidgin' (head 3d1e6b8637ff9133c8f17e9aeaeea1284c898d86) to branch 'im.pidgin.pidgin.yaz' (head cf1ed778db33093adccaec9aa0399ac72a0b712f) diff -r 295777a9e2a4 -r 67ad619bd97f COPYRIGHT --- a/COPYRIGHT Sat Jun 02 15:41:36 2007 +0000 +++ b/COPYRIGHT Mon Jun 04 07:22:38 2007 +0000 @@ -8,6 +8,7 @@ Dave Ahlswede Manuel Amador Matt Amato +Elliott Sales de Andrade Geoffrey Antos Daniel Atallah Paul Aurich diff -r 295777a9e2a4 -r 67ad619bd97f ChangeLog --- a/ChangeLog Sat Jun 02 15:41:36 2007 +0000 +++ b/ChangeLog Mon Jun 04 07:22:38 2007 +0000 @@ -3,12 +3,16 @@ version 2.0.2 (??/??/????): Pidgin: * Added a custom conversation font option to preferences + * Fixed smiley ordering in the insert smiley popup to be more intuitive libpurple: * Moving an ICQ buddy from one group to another no longer re-requests authorization from that person (Rene Hausleitner) * Added nullprpl, an example protocol plugin (Ryan Barrett) * Fixed SOCKS5 bug which caused Jabber file receiving to fail + * Remove MSN's random "Authorization Failed" dialogs + * Fix MSN to correctly detect incorrect passwords and disable the account + * Get User Info on MSN is now more reliable & accurate Finch: * Auto account reconnecting diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/idle.c --- a/libpurple/idle.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/idle.c Mon Jun 04 07:22:38 2007 +0000 @@ -121,7 +121,7 @@ gboolean report_idle; GList *l; gint away_seconds = 0; - gint idle_recheck_interval; + gint idle_recheck_interval = 0; purple_signal_emit(purple_blist_get_handle(), "update-idle"); diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/plugins/joinpart.c --- a/libpurple/plugins/joinpart.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/plugins/joinpart.c Mon Jun 04 07:22:38 2007 +0000 @@ -210,7 +210,7 @@ * we don't have to worry one will be called after this. */ g_hash_table_destroy((GHashTable *)data[0]); - g_source_remove(GPOINTER_TO_UINT(data[1])); + purple_timeout_remove(GPOINTER_TO_UINT(data[1])); g_free(data); return TRUE; diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/plugins/log_reader.c --- a/libpurple/plugins/log_reader.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/plugins/log_reader.c Mon Jun 04 07:22:38 2007 +0000 @@ -1482,46 +1482,66 @@ * "> * Then, replace the next " " (or add this if the end-of-line is reached) with: * + * + * As implemented, this isn't perfect, but it should cover common cases. */ link_temp_line = NULL; - while ((link = g_strstr_len(line, strlen(line), "(Link: "))) { - GString *temp; + while ((link = strstr(line, "(Link: "))) + { + char *tmp = link; - if (!*link) - continue; + link += 7; + if (*link) + { + char *end_paren; + char *space; + GString *temp; - *link = '\0'; - link++; + if (!(end_paren = strstr(link, ")"))) + { + /* Something is not as we expect. Bail out. */ + break; + } - temp = g_string_new(line); - g_string_append(temp, " tag. */ + g_string_append(temp, "= 6) { - link += (sizeof("(Link: ") - 1); + /* Finish the tag. */ + g_string_append(temp, "\">"); + + /* The \r is a bit of a hack to keep there from being a \r in + * the link text, which may not matter. */ + if ((space = strstr(end_paren, " ")) || (space = strstr(end_paren, "\r"))) + { + g_string_append_len(temp, end_paren + 1, space - end_paren - 1); - while (*link && *link != ')') { - g_string_append_c(temp, *link); - link++; + /* Close the tag. */ + g_string_append(temp, ""); + + space++; + if (*space) + { + g_string_append_c(temp, ' '); + /* Keep the rest of the line. */ + g_string_append(temp, space); + } } - if (link) { - link++; - - g_string_append(temp, "\">"); - while (*link && *link != ' ') { - g_string_append_c(temp, *link); - link++; - } + else + { + /* There is no space before the end of the line. */ + g_string_append(temp, end_paren + 1); + /* Close the tag. */ g_string_append(temp, ""); } - g_string_append(temp, link); - - /* Free the last round's line. */ - if (link_temp_line) - g_free(line); - - line = temp->str; - g_string_free(temp, FALSE); + g_free(link_temp_line); + line = g_string_free(temp, FALSE); /* Save this memory location so we can free it later. */ link_temp_line = line; @@ -1661,8 +1681,7 @@ g_string_append_c(formatted, '\n'); - if (link_temp_line) - g_free(link_temp_line); + g_free(link_temp_line); c++; line = c; diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/plugins/perl/perl-handlers.c --- a/libpurple/plugins/perl/perl-handlers.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/plugins/perl/perl-handlers.c Mon Jun 04 07:22:38 2007 +0000 @@ -184,7 +184,7 @@ timeout_handlers = g_list_remove(timeout_handlers, handler); if (handler->iotag > 0) - g_source_remove(handler->iotag); + purple_timeout_remove(handler->iotag); if (handler->callback != NULL) SvREFCNT_dec(handler->callback); @@ -405,7 +405,7 @@ timeout_handlers = g_list_append(timeout_handlers, handler); - handler->iotag = g_timeout_add(seconds * 1000, perl_timeout_cb, handler); + handler->iotag = purple_timeout_add(seconds * 1000, perl_timeout_cb, handler); } void diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/Makefile.am --- a/libpurple/protocols/Makefile.am Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/Makefile.am Mon Jun 04 07:22:38 2007 +0000 @@ -1,4 +1,4 @@ -EXTRA_DIST = Makefile.mingw null/ +EXTRA_DIST = Makefile.mingw DIST_SUBDIRS = bonjour gg irc jabber msn novell null oscar qq sametime silc toc simple yahoo zephyr diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/msn/msn.c Mon Jun 04 07:22:38 2007 +0000 @@ -1432,6 +1432,22 @@ if (found) \ sect_info = TRUE; +#define MSN_GOT_INFO_GET_FIELD_NO_SEARCH(a, b) \ + found = purple_markup_extract_info_field(stripped, stripped_len, user_info, \ + "\n" a ":", 0, "\n", 0, "Undisclosed", b, 0, NULL, msn_info_strip_search_link); \ + if (found) \ + sect_info = TRUE; + +static char * +msn_info_strip_search_link(const char *field, size_t len) +{ + const char *c; + if ((c = strstr(field, " (http://spaces.live.com/default.aspx?page=searchresults")) == NULL && + (c = strstr(field, " (http://spaces.msn.com/default.aspx?page=searchresults")) == NULL) + return g_strndup(field, len); + return g_strndup(field, c - field); +} + static void msn_got_info(PurpleUtilFetchUrlData *url_data, gpointer data, const gchar *url_text, size_t len, const gchar *error_message) @@ -1547,10 +1563,10 @@ /* General */ MSN_GOT_INFO_GET_FIELD("Nickname", _("Nickname")); - MSN_GOT_INFO_GET_FIELD("Age", _("Age")); - MSN_GOT_INFO_GET_FIELD("Gender", _("Gender")); - MSN_GOT_INFO_GET_FIELD("Occupation", _("Occupation")); - MSN_GOT_INFO_GET_FIELD("Location", _("Location")); + MSN_GOT_INFO_GET_FIELD_NO_SEARCH("Age", _("Age")); + MSN_GOT_INFO_GET_FIELD_NO_SEARCH("Gender", _("Gender")); + MSN_GOT_INFO_GET_FIELD_NO_SEARCH("Occupation", _("Occupation")); + MSN_GOT_INFO_GET_FIELD_NO_SEARCH("Location", _("Location")); /* Extract their Interests and put it in */ found = purple_markup_extract_info_field(stripped, stripped_len, user_info, @@ -1811,7 +1827,10 @@ /* This doesn't work with the new spaces profiles - Stu 3/2/06 char *p = strstr(url_buffer, "Unknown Member "); * This might not work for long either ... */ + /* Nope, it failed some time before 5/2/07 :( char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\""); + * Let's see how long this one holds out for ... */ + char *p = strstr(url_buffer, "
gc), info_data->name); purple_notify_user_info_add_pair(user_info, _("Error retrieving profile"), diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/msn/msn.h --- a/libpurple/protocols/msn/msn.h Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/msn/msn.h Mon Jun 04 07:22:38 2007 +0000 @@ -67,7 +67,7 @@ #define HOTMAIL_URL "http://www.hotmail.com/cgi-bin/folders" #define PASSPORT_URL "http://lc1.law13.hotmail.passport.com/cgi-bin/dologin?login=" -#define PROFILE_URL "http://spaces.msn.com/profile.aspx?mem=" +#define PROFILE_URL "http://spaces.live.com/profile.aspx?mem=" #define USEROPT_HOTMAIL 0 diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/msn/switchboard.c --- a/libpurple/protocols/msn/switchboard.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/msn/switchboard.c Mon Jun 04 07:22:38 2007 +0000 @@ -419,7 +419,14 @@ case MSN_SB_ERROR_TOO_FAST: str_reason = _("Message could not be sent " "because we are sending too quickly:"); - break; + break; + case MSN_SB_ERROR_AUTHFAILED: + str_reason = _("Message could not be sent " + "because we wer unable to establish a " + "session with the server. This is " + "likely a server problem, try again in " + "a few minutes:"); + break; default: str_reason = _("Message could not be sent " "because an error with " @@ -967,9 +974,13 @@ * Connect stuff **************************************************************************/ static void +ans_usr_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error); + +static void connect_cb(MsnServConn *servconn) { MsnSwitchBoard *swboard; + MsnTransaction *trans; MsnCmdProc *cmdproc; PurpleAccount *account; @@ -984,16 +995,44 @@ { swboard->empty = FALSE; - msn_cmdproc_send(cmdproc, "ANS", "%s %s %s", - purple_account_get_username(account), - swboard->auth_key, swboard->session_id); + trans = msn_transaction_new(cmdproc, "ANS", "%s %s %s", + purple_account_get_username(account), + swboard->auth_key, swboard->session_id); } else { - msn_cmdproc_send(cmdproc, "USR", "%s %s", - purple_account_get_username(account), - swboard->auth_key); + trans = msn_transaction_new(cmdproc, "USR", "%s %s", + purple_account_get_username(account), + swboard->auth_key); } + + msn_transaction_set_error_cb(trans, ans_usr_error); + msn_transaction_set_data(trans, swboard); + msn_cmdproc_send_trans(cmdproc, trans); +} + +static void +ans_usr_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) +{ + MsnSwitchBoard *swboard; + char **params; + char *passport; + int reason = MSN_SB_ERROR_UNKNOWN; + + if (error == 911) + { + reason = MSN_SB_ERROR_AUTHFAILED; + } + + purple_debug_warning("msn", "ans_usr_error: command %s gave error %i\n", trans->command, error); + + params = g_strsplit(trans->params, " ", 0); + passport = params[0]; + swboard = trans->data; + + swboard_error_helper(swboard, reason, passport); + + g_strfreev(params); } static void diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/msn/switchboard.h --- a/libpurple/protocols/msn/switchboard.h Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/msn/switchboard.h Mon Jun 04 07:22:38 2007 +0000 @@ -46,6 +46,7 @@ MSN_SB_ERROR_USER_OFFLINE, /**< The user to call is offline. */ MSN_SB_ERROR_CONNECTION, /**< There was a connection error. */ MSN_SB_ERROR_TOO_FAST, /**< We are sending too fast */ + MSN_SB_ERROR_AUTHFAILED, /**< Authentication failed joining the switchboard session */ MSN_SB_ERROR_UNKNOWN /**< An unknown error occurred. */ } MsnSBErrorType; diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/null/nullprpl.c --- a/libpurple/protocols/null/nullprpl.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/null/nullprpl.c Mon Jun 04 07:22:38 2007 +0000 @@ -432,7 +432,7 @@ from_username, who, message); /* is the sender blocked by the recipient's privacy settings? */ - if (!purple_privacy_check(to_acct, gc->account->username)) { + if (to_acct && !purple_privacy_check(to_acct, gc->account->username)) { char *msg = g_strdup_printf( _("Your message was blocked by %s's privacy settings."), who); purple_debug_info("nullprpl", diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/oscar/flap_connection.c --- a/libpurple/protocols/oscar/flap_connection.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/oscar/flap_connection.c Mon Jun 04 07:22:38 2007 +0000 @@ -303,7 +303,7 @@ } } - if (conn->fd != -1) + if (conn->fd >= 0) { if (conn->type == SNAC_FAMILY_LOCATE) flap_connection_send_close(od, conn); @@ -792,7 +792,7 @@ } /* If there was an error then close the connection */ - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -853,7 +853,7 @@ break; } - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -902,7 +902,7 @@ ret = send(conn->fd, conn->buffer_outgoing->outptr, writelen, 0); if (ret <= 0) { - if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) + if (ret < 0 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) /* No worries */ return; @@ -936,7 +936,7 @@ purple_circ_buffer_append(conn->buffer_outgoing, bs->data, count); /* If we haven't already started writing stuff, then start the cycle */ - if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) + if ((conn->watcher_outgoing == 0) && (conn->fd >= 0)) { conn->watcher_outgoing = purple_input_add(conn->fd, PURPLE_INPUT_WRITE, send_cb, conn); diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/oscar/odc.c --- a/libpurple/protocols/oscar/odc.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/oscar/odc.c Mon Jun 04 07:22:38 2007 +0000 @@ -447,7 +447,7 @@ return; } - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/oscar/oscar.c --- a/libpurple/protocols/oscar/oscar.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/oscar/oscar.c Mon Jun 04 07:22:38 2007 +0000 @@ -1625,8 +1625,7 @@ straight_to_hell, pos) == NULL) { char buf[256]; - if (pos->modname) - g_free(pos->modname); + g_free(pos->modname); g_free(pos); g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. " "Check %s for updates."), PURPLE_WEBSITE); diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/oscar/peer.c --- a/libpurple/protocols/oscar/peer.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/oscar/peer.c Mon Jun 04 07:22:38 2007 +0000 @@ -173,12 +173,12 @@ purple_input_remove(conn->watcher_outgoing); conn->watcher_outgoing = 0; } - if (conn->listenerfd != -1) + if (conn->listenerfd >= 0) { close(conn->listenerfd); conn->listenerfd = -1; } - if (conn->fd != -1) + if (conn->fd >= 0) { close(conn->fd); conn->fd = -1; @@ -310,7 +310,7 @@ } /* If there was an error then close the connection */ - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -360,7 +360,7 @@ return; } - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -422,7 +422,7 @@ wrotelen = send(conn->fd, conn->buffer_outgoing->outptr, writelen, 0); if (wrotelen <= 0) { - if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) + if (wrotelen < 0 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) /* No worries */ return; @@ -462,7 +462,7 @@ purple_circ_buffer_append(conn->buffer_outgoing, bs->data, bs->len); /* If we haven't already started writing stuff, then start the cycle */ - if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) + if ((conn->watcher_outgoing == 0) && (conn->fd >= 0)) { conn->watcher_outgoing = purple_input_add(conn->fd, PURPLE_INPUT_WRITE, send_cb, conn); @@ -596,7 +596,7 @@ purple_debug_info("oscar", "Accepting connection on listener socket.\n"); conn->fd = accept(conn->listenerfd, &addr, &addrlen); - if (conn->fd == -1) + if (conn->fd < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No connection yet--no worries */ @@ -640,7 +640,7 @@ conn = data; conn->listen_data = NULL; - if (listenerfd == -1) + if (listenerfd < 0) { /* Could not open listener socket */ peer_connection_trynext(conn); diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/oscar/peer_proxy.c --- a/libpurple/protocols/oscar/peer_proxy.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/oscar/peer_proxy.c Mon Jun 04 07:22:38 2007 +0000 @@ -224,7 +224,7 @@ } /* If there was an error then close the connection */ - if (read == -1) + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ @@ -285,7 +285,8 @@ return; } - if (read == -1) + /* If there was an error then close the connection */ + if (read < 0) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) /* No worries */ diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/silc/silc.c --- a/libpurple/protocols/silc/silc.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/silc/silc.c Mon Jun 04 07:22:38 2007 +0000 @@ -119,12 +119,12 @@ NULL, 0); } -static int +static gboolean silcpurple_scheduler(gpointer *context) { SilcPurple sg = (SilcPurple)context; silc_client_run_one(sg->client); - return 1; + return TRUE; } static void @@ -361,11 +361,7 @@ } /* Schedule SILC using Glib's event loop */ -#ifndef _WIN32 - sg->scheduler = g_timeout_add(5, (GSourceFunc)silcpurple_scheduler, sg); -#else - sg->scheduler = g_timeout_add(300, (GSourceFunc)silcpurple_scheduler, sg); -#endif + sg->scheduler = purple_timeout_add(300, (GSourceFunc)silcpurple_scheduler, sg); } static int @@ -396,8 +392,8 @@ if (sg->conn) silc_client_close_connection(sg->client, sg->conn); - g_source_remove(sg->scheduler); - g_timeout_add(1, (GSourceFunc)silcpurple_close_final, sg); + purple_timeout_remove(sg->scheduler); + purple_timeout_add(1, (GSourceFunc)silcpurple_close_final, sg); } diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/yahoo/yahoo.c --- a/libpurple/protocols/yahoo/yahoo.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Mon Jun 04 07:22:38 2007 +0000 @@ -2310,7 +2310,7 @@ * are you trying to pull? */ guchar *start; - purple_debug_warning("yahoo", "Error in YMSG stream, got something not a YMSG packet!"); + purple_debug_warning("yahoo", "Error in YMSG stream, got something not a YMSG packet!\n"); start = memchr(yd->rxqueue + 1, 'Y', yd->rxlen - 1); if (start) { @@ -2377,7 +2377,11 @@ } if (source < 0) { - purple_connection_error(gc, _("Unable to connect.")); + gchar *tmp; + tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), + error_message); + purple_connection_error(gc, tmp); + g_free(tmp); return; } @@ -2405,7 +2409,11 @@ } if (source < 0) { - purple_connection_error(gc, _("Unable to connect.")); + gchar *tmp; + tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), + error_message); + purple_connection_error(gc, tmp); + g_free(tmp); return; } @@ -2507,12 +2515,16 @@ if (written < 0 && errno == EAGAIN) written = 0; else if (written <= 0) { + gchar *tmp; g_free(yd->auth); yd->auth = NULL; if (gc->inpa) purple_input_remove(gc->inpa); gc->inpa = 0; - purple_connection_error(gc, _("Unable to connect.")); + tmp = g_strdup_printf(_("Lost connection with %s:\n%s"), + "login.yahoo.com:80", strerror(errno)); + purple_connection_error(gc, tmp); + g_free(tmp); return; } @@ -2533,7 +2545,11 @@ PurpleConnection *gc = data; if (source < 0) { - purple_connection_error(gc, _("Unable to connect.")); + gchar *tmp; + tmp = g_strdup_printf(_("Could not establish a connection with %s:\n%s"), + "login.yahoo.com:80", error_message); + purple_connection_error(gc, tmp); + g_free(tmp); return; } @@ -2616,8 +2632,7 @@ if (error_message != NULL) { - /* TODO: Include error_message in the message below */ - purple_connection_error(gc, _("Unable to connect.")); + purple_connection_error(gc, error_message); return; } diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/protocols/yahoo/yahoo_packet.c --- a/libpurple/protocols/yahoo/yahoo_packet.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/protocols/yahoo/yahoo_packet.c Mon Jun 04 07:22:38 2007 +0000 @@ -114,6 +114,29 @@ return len; } +/* + * 'len' is the value given to us by the server that is supposed to + * be the length of 'data'. But apparently there's a time when this + * length is incorrect. Christopher Layne thinks it might be a bug + * in their server code. + * + * The following information is from Christopher: + * + * It sometimes happens when Yahoo! sends a packet continuation within + * chat. Sometimes when joining a large chatroom the initial + * SERVICE_CHATJOIN packet will be so large that it will need to be + * split into multiple packets. That's fine, except that the length + * of the second packet is wrong. The packet has the same length as + * the first packet, and the length given in the header is the same, + * however the actual data in the packet is shorter than this length. + * So half of the packet contains good, valid data, and then the rest + * of the packet is junk. Luckily there is a null terminator after + * the valid data and before the invalid data. + * + * What does all this mean? It means that we parse through the data + * pulling out key/value pairs until we've parsed 'len' bytes, or until + * we run into a null terminator, whichever comes first. + */ void yahoo_packet_read(struct yahoo_packet *pkt, const guchar *data, int len) { int pos = 0; @@ -125,18 +148,8 @@ while (pos + 1 < len) { - /* this is weird, and in one of the chat packets, and causes us to - * think all the values are keys and all the keys are values after - * this point if we don't handle it */ - if (data[pos] == '\0') { - while (pos + 1 < len) { - if (data[pos] == 0xc0 && data[pos + 1] == 0x80) - break; - pos++; - } - pos += 2; - continue; - } + if (data[pos] == '\0') + break; pair = g_new0(struct yahoo_pair, 1); diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/purple-remote --- a/libpurple/purple-remote Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/purple-remote Mon Jun 04 07:22:38 2007 +0000 @@ -31,7 +31,7 @@ return result def show_help(): - print """This program uses DBus to communicate with purple. + print """This program uses D-Bus to communicate with purple. Usage: @@ -96,8 +96,6 @@ protocol = match.group(2) if protocol == "xmpp": protocol = "jabber" - if protocol == "aim" or protocol == "icq": - protocol = "oscar" if protocol is not None: protocol = "prpl-" + protocol command = match.group(5) diff -r 295777a9e2a4 -r 67ad619bd97f libpurple/util.c --- a/libpurple/util.c Sat Jun 02 15:41:36 2007 +0000 +++ b/libpurple/util.c Mon Jun 04 07:22:38 2007 +0000 @@ -46,6 +46,7 @@ } website; char *url; + int num_times_redirected; gboolean full; char *user_agent; gboolean http11; @@ -1261,14 +1262,17 @@ pt->dest_tag = y; \ tags = g_list_prepend(tags, pt); \ } \ - xhtml = g_string_append(xhtml, "<" y); \ - c += strlen("<" x ); \ - xhtml = g_string_append(xhtml, innards->str); \ - xhtml = g_string_append_c(xhtml, '>'); \ + if(xhtml) { \ + xhtml = g_string_append(xhtml, "<" y); \ + xhtml = g_string_append(xhtml, innards->str); \ + xhtml = g_string_append_c(xhtml, '>'); \ + } \ c = p + 1; \ } else { \ - xhtml = g_string_append(xhtml, "<"); \ - plain = g_string_append_c(plain, '<'); \ + if(xhtml) \ + xhtml = g_string_append(xhtml, "<"); \ + if(plain) \ + plain = g_string_append_c(plain, '<'); \ c++; \ } \ g_string_free(innards, TRUE); \ @@ -1277,16 +1281,19 @@ if(!g_ascii_strncasecmp(c, "<" x, strlen("<" x)) && \ (*(c+strlen("<" x)) == '>' || \ !g_ascii_strncasecmp(c+strlen("<" x), "/>", 2))) { \ - xhtml = g_string_append(xhtml, "<" y); \ + if(xhtml) \ + xhtml = g_string_append(xhtml, "<" y); \ c += strlen("<" x); \ if(*c != '/') { \ struct purple_parse_tag *pt = g_new0(struct purple_parse_tag, 1); \ pt->src_tag = x; \ pt->dest_tag = y; \ tags = g_list_prepend(tags, pt); \ - xhtml = g_string_append_c(xhtml, '>'); \ + if(xhtml) \ + xhtml = g_string_append_c(xhtml, '>'); \ } else { \ - xhtml = g_string_append(xhtml, "/>");\ + if(xhtml) \ + xhtml = g_string_append(xhtml, "/>");\ } \ c = strchr(c, '>') + 1; \ continue; \ @@ -1296,11 +1303,18 @@ purple_markup_html_to_xhtml(const char *html, char **xhtml_out, char **plain_out) { - GString *xhtml = g_string_new(""); - GString *plain = g_string_new(""); + GString *xhtml = NULL; + GString *plain = NULL; GList *tags = NULL, *tag; const char *c = html; + g_return_if_fail(xhtml_out != NULL || plain_out != NULL); + + if(xhtml_out) + xhtml = g_string_new(""); + if(plain_out) + plain = g_string_new(""); + while(c && *c) { if(*c == '<') { if(*(c+1) == '/') { /* closing tag */ @@ -1316,7 +1330,8 @@ if(tag) { while(tags) { struct purple_parse_tag *pt = tags->data; - g_string_append_printf(xhtml, "", pt->dest_tag); + if(xhtml) + g_string_append_printf(xhtml, "", pt->dest_tag); if(tags == tag) break; tags = g_list_remove(tags, pt); @@ -1334,8 +1349,10 @@ if(*end == '>') { c = end+1; } else { - xhtml = g_string_append(xhtml, "<"); - plain = g_string_append_c(plain, '<'); + if(xhtml) + xhtml = g_string_append(xhtml, "<"); + if(plain) + plain = g_string_append_c(plain, '<'); c++; } } @@ -1364,7 +1381,8 @@ ALLOW_TAG("span"); ALLOW_TAG("strong"); ALLOW_TAG("ul"); - + ALLOW_TAG("img"); + /* we skip
because it's not legal in XHTML-IM. However, * we still want to send something sensible, so we put a * linebreak in its place.
also needs special handling @@ -1375,8 +1393,9 @@ !g_ascii_strncasecmp(c+3, "/>", 2) || !g_ascii_strncasecmp(c+3, " />", 3))) { c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, "
"); - if(*c != '\n') + if(xhtml) + xhtml = g_string_append(xhtml, "
"); + if(plain && *c != '\n') plain = g_string_append_c(plain, '\n'); continue; } @@ -1386,7 +1405,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if(xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "", 3) || !g_ascii_strncasecmp(c, "", strlen(""))) { @@ -1395,7 +1415,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if (xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "", 3) || !g_ascii_strncasecmp(c, "", strlen(""))) { @@ -1404,7 +1425,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if(xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "", 5)) { @@ -1413,7 +1435,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if(xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "", 5)) { @@ -1422,7 +1445,8 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); c = strchr(c, '>') + 1; - xhtml = g_string_append(xhtml, ""); + if(xhtml) + xhtml = g_string_append(xhtml, ""); continue; } if(!g_ascii_strncasecmp(c, "' || *(c+5) == ' ')) { @@ -1516,7 +1540,10 @@ pt->dest_tag = "span"; tags = g_list_prepend(tags, pt); if(style->len) - g_string_append_printf(xhtml, "", g_strstrip(style->str)); + { + if(xhtml) + g_string_append_printf(xhtml, "", g_strstrip(style->str)); + } else pt->ignore = TRUE; g_string_free(style, TRUE); @@ -1536,7 +1563,8 @@ color = g_string_append_c(color, *q); q++; } - g_string_append_printf(xhtml, "", g_strstrip(color->str)); + if(xhtml) + g_string_append_printf(xhtml, "", g_strstrip(color->str)); g_string_free(color, TRUE); if ((c = strchr(c, '>')) != NULL) c++; @@ -1557,14 +1585,17 @@ if(!g_ascii_strncasecmp(c, ""); if(p) { - xhtml = g_string_append(xhtml, "