Mercurial > pidgin.yaz
changeset 1754:6e51e206a388
[gaim-migrate @ 1764]
URL decoding in the MSN stuff. Yay.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Thu, 26 Apr 2001 22:15:46 +0000 |
parents | ee578ccaa5f1 |
children | 300dcb2aa120 |
files | ChangeLog plugins/msn/msn.c |
diffstat | 2 files changed, 71 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Apr 26 01:51:19 2001 +0000 +++ b/ChangeLog Thu Apr 26 22:15:46 2001 +0000 @@ -14,8 +14,9 @@ (thanks Neil Sanchala) * Some perl updates (thanks to Sean Egan) * IRC got the following slash commands: - op, deop, voice, devoice, mode, raw, quote, and kick (thanks + op, deop, voice, devoice, mode, raw, quote, and kick (thanks to Sean Egan) + * MSN Properly handles URL decoding of 'friendly' names version 0.11.0-pre10 (04/13/2001): * Many, many bug fixes
--- a/plugins/msn/msn.c Thu Apr 26 01:51:19 2001 +0000 +++ b/plugins/msn/msn.c Thu Apr 26 22:15:46 2001 +0000 @@ -106,6 +106,73 @@ void msn_des_win(GtkWidget *a, GtkWidget *b); void msn_newmail_dialog(const char *text); +char tochar(char *h) +{ + char alphabet[] = "0123456789abcdef"; + char tmp; + char b; + int v = 0; + int i; + + for (i = strlen(h); i > 0; i--) + { + tmp = tolower(h[strlen(h) - i]); + + if (tmp >= '0' && tmp <= '9') + b = tmp - '0'; + else if (tmp >= 'a' && tmp <= 'f') + b = (tmp - 'a') + 10; + + if (i > 1) + v =+ ((i-1) * 16) * b; + else + v += b; + } + + return v; +} + +char *url_decode(char *text) +{ + static char newtext[MSN_BUF_LEN]; + char *buf; + int c = 0; + int i = 0; + int j = 0; + + for (i = 0; i < strlen(text); i++) + { + if (text[i] == '%') + c++; + } + + buf = (char *)malloc(strlen(text) + c + 1); + + for (i = 0, j = 0 ; text[i] != 0; i++) + { + if (text[i] != '%') + { + buf[j++] = text[i]; + } + else + { + char hex[3]; + hex[0] = text[++i]; + hex[1] = text[++i]; + hex[2] = 0; + + buf[j++] = tochar(hex); + } + } + + for (i = 0; i < strlen(buf); i++) + newtext[i] = buf[i]; + + free(buf); + + return newtext; +} + void msn_accept_add_permit(gpointer w, struct msn_ask_add_permit *ap) { msn_add_permit(ap->gc, ap->user); @@ -227,7 +294,7 @@ snprintf(buf, MSN_BUF_LEN, "The user %s (%s) wants to add you to their buddylist.", res[4], res[5]); ap->user = g_strdup(res[4]); - ap->friendly = g_strdup(res[5]); + ap->friendly = url_decode(res[5]); ap->gc = gc; do_ask_dialog(buf, ap, (GtkFunction) msn_accept_add_permit, (GtkFunction) msn_cancel_add_permit); @@ -767,7 +834,7 @@ } else { - md->friendly = g_strdup(res[4]); + md->friendly = url_decode(res[4]); /* Ok, ok. Your account is FINALLY online. Ya think Microsoft * could have had any more steps involved? */