Mercurial > pidgin
changeset 23547:3249c367577b
When sending MSN OIM's, wrap Base64'd text at 76 characters. Because
it's Base64-encoded, this problem doesn't necessarily occur at exactly
76 characters of text to *send*.
Really fixes #5379.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Tue, 15 Jul 2008 01:42:01 +0000 |
parents | 48024418982c |
children | 8c2650fb7253 |
files | libpurple/protocols/msn/oim.c |
diffstat | 1 files changed, 22 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/oim.c Mon Jul 14 04:55:34 2008 +0000 +++ b/libpurple/protocols/msn/oim.c Tue Jul 15 01:42:01 2008 +0000 @@ -270,16 +270,31 @@ static gchar * msn_oim_msg_to_str(MsnOim *oim, const char *body) { - char *oim_body,*oim_base64; + GString *oim_body; + char *oim_base64; + char *c; + int len; + + purple_debug_info("msn", "Encoding OIM Message...\n"); + len = strlen(body); + c = oim_base64 = purple_base64_encode((const guchar *)body, len); + purple_debug_info("msn", "Encoded base64 body:{%s}\n", oim_base64); - purple_debug_info("msn", "encode OIM Message...\n"); - oim_base64 = purple_base64_encode((const guchar *)body, strlen(body)); - purple_debug_info("msn", "encoded base64 body:{%s}\n", oim_base64); - oim_body = g_strdup_printf(MSN_OIM_MSG_TEMPLATE, - oim->run_id,oim->send_seq,oim_base64); + oim_body = g_string_new(NULL); + g_string_printf(oim_body, MSN_OIM_MSG_TEMPLATE, + oim->run_id, oim->send_seq); + + len = ((len / 3) + 1) * 4 - 76; + while ((c - oim_base64) < len) { + g_string_append_len(oim_body, c, 76); + g_string_append_c(oim_body, '\n'); + c += 76; + } + g_string_append(oim_body, c); + g_free(oim_base64); - return oim_body; + return g_string_free(oim_body, FALSE); } /*