From 77249679e5a2ce8953b93c4e92c35b26bbd8fc0c Mon Sep 17 00:00:00 2001 From: ajc Date: Thu, 19 Mar 2009 04:32:15 +0000 Subject: [PATCH] * When using the javascript instant messenger screen, transmit outgoing messages to webcit using a real webcit command (new command: ajax_send_instant_message) instead of the ajax_server_cmd framework. This gives us string unescaping for free, so we now escape all strings before transmitting them. I was hoping this would fix the problem with sending non-ASCII characters through the instant messenger, but it didn't. This will probably still be part of the solution though. git-svn-id: svn://uncensored.citadel.org/trunk@7231 c9418f8e-8c02-0410-9258-ad310909226a --- webcit/paging.c | 32 +++++++++++++++++++++++--------- webcit/static/instant_messenger.html | 5 +++-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/webcit/paging.c b/webcit/paging.c index d3319f12..7f81049d 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -1,15 +1,11 @@ /* * $Id$ */ -/** - * \defgroup PageFunc Functions which implement the chat and paging facilities. - * \ingroup ClientPower - */ -/*@{*/ + #include "webcit.h" -/** - * \brief display the form for paging (x-messaging) another user +/* + * display the form for paging (x-messaging) another user */ void display_page(void) { @@ -501,6 +497,25 @@ void chat_send(void) { wDumpContent(0); } + +void ajax_send_instant_message(void) { + char recp[256]; + char buf[256]; + + safestrncpy(recp, bstr("recp"), sizeof recp); + + serv_printf("SEXP %s|-", recp); + serv_getln(buf, sizeof buf); + + if (buf[0] == '4') { + text_to_server(bstr("msg")); + serv_puts("000"); + } + + escputs(buf); /* doesn't really matter what we return - the client ignores it */ +} + + void InitModule_PAGING (void) @@ -510,6 +525,5 @@ InitModule_PAGING WebcitAddUrlHandler(HKEY("chat"), do_chat, 0); WebcitAddUrlHandler(HKEY("chat_recv"), chat_recv, 0); WebcitAddUrlHandler(HKEY("chat_send"), chat_send, 0); + WebcitAddUrlHandler(HKEY("ajax_send_instant_message"), ajax_send_instant_message, AJAX); } - -/*@}*/ diff --git a/webcit/static/instant_messenger.html b/webcit/static/instant_messenger.html index 4af6387b..b86cb5a6 100644 --- a/webcit/static/instant_messenger.html +++ b/webcit/static/instant_messenger.html @@ -55,8 +55,9 @@ function SendSomething(which_div, sendform, recipient) { // Send the text to the server parms = 'r=' + Math.random() - + '&g_cmd=SEXP ' + recipient + '|-\n' + escape(thetext); - new Ajax.Request('../ajax_servcmd', + + '&recp=' + recipient + + '&msg=' + escape(thetext); + new Ajax.Request('../ajax_send_instant_message', { method: 'post', parameters: parms -- 2.11.4.GIT