# HG changeset patch # User Rob Flynn # Date 991693613 0 # Node ID db6f447a6d916fc8ee743cb4e01aa8b118ae5ac9 # Parent 741842331ceb4553581d2f98c578ee5982af09c4 [gaim-migrate @ 1970] MSN escapes messages properly. committer: Tailor Script diff -r 741842331ceb -r db6f447a6d91 ChangeLog --- a/ChangeLog Mon Jun 04 20:13:34 2001 +0000 +++ b/ChangeLog Mon Jun 04 22:26:53 2001 +0000 @@ -7,6 +7,7 @@ * HTML is properly stripped from away messages in protocols that do not use HTML. (thanks, faceprint) * Can view/set chat topic in IRC + * MSN properly escapes outgoing messages version 0.11.0-pre12 (05/29/2001): * Fixed a funny bug with auto responses when queued messages diff -r 741842331ceb -r db6f447a6d91 plugins/msn/msn.c --- a/plugins/msn/msn.c Mon Jun 04 20:13:34 2001 +0000 +++ b/plugins/msn/msn.c Mon Jun 04 22:26:53 2001 +0000 @@ -143,6 +143,41 @@ return v; } +static char *url_encode(unsigned char *text, int dospace) +{ + static char newtext[MSN_BUF_LEN*2]; + char *buf; + char *temp = (char *)malloc(4); + int c = 0; + int i = 0; + int j = 0; + + bzero(newtext, MSN_BUF_LEN*2); + + for (j = 0; j < strlen(text); j++) + { + if ((text[j] < 33) || (text[j] > 126) || (text[j] == 32 && dospace==1)) + { + /* Other wise, we should escape this booger */ + newtext[i++] = '%'; + sprintf(temp, "%02x", text[j]); + newtext[i++] = temp[0]; + newtext[i++] = temp[1]; + } + else + { + /* It's ok to store this one, sarge */ + newtext[i++] = text[j]; + } + } + + newtext[i] = 0; + + free(temp); + + return newtext; +} + static char *url_decode(char *text) { static char newtext[MSN_BUF_LEN]; @@ -151,6 +186,8 @@ int i = 0; int j = 0; + bzero(newtext, MSN_BUF_LEN); + for (i = 0; i < strlen(text); i++) { if (text[i] == '%') c++; @@ -811,9 +848,7 @@ hide_login_progress(gc, "Error signing on"); signoff(gc); } else { - debug_printf("Before: %s\n", res[4]); md->friendly = g_strdup(url_decode(res[4])); - debug_printf("After: %s\n", md->friendly); /* Ok, ok. Your account is FINALLY online. Ya think Microsoft * could have had any more steps involved? */ @@ -935,7 +970,7 @@ g_snprintf(buf, MSN_BUF_LEN, "MSG %ld N %d\r\n%s%s", trId(md), strlen(message) + strlen(MIME_HEADER), MIME_HEADER, message); - msn_write(mc->fd, buf); + msn_write(mc->fd, url_encode(buf, 0)); } } @@ -1280,10 +1315,15 @@ struct msn_data *md = (struct msn_data *)gc->proto_data; char buf[MSN_BUF_LEN - 1]; const gchar *newname; + char *temp; newname = gtk_entry_get_text(GTK_ENTRY(b->entry)); + + temp = strdup(newname); - snprintf(buf, MSN_BUF_LEN, "REA %ld %s %s\n", trId(md), gc->username, newname); + snprintf(buf, MSN_BUF_LEN, "REA %ld %s %s\n", trId(md), gc->username, url_encode(temp, 1)); + + free(temp); msn_write(md->fd, buf); @@ -1330,7 +1370,7 @@ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); buf = g_malloc(256); - g_snprintf(buf, 256, "New name for %s (%s):", tmp->username, md->friendly); + g_snprintf(buf, 256, "New name for %s (%s):", tmp->username, url_decode(md->friendly)); label = gtk_label_new(buf); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); gtk_widget_show(label);