aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/nogaim.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2007-07-15 16:47:34 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2007-07-15 16:47:34 +0100
commit85023c65b697d2dab932acbda31258ae5270dbe6 (patch)
tree5ecc35fc39a5f71f0c68b4c0497d5431bef90b9a /protocols/nogaim.c
parent1ffb46f027f501da45951428e097f69ced1c80e0 (diff)
Added imcb_clean_handle() to sanitize handles properly (without putting
IRC-specific stuff into the Jabber module). Only using this in the MUC code for now because this only works if the IM module can somehow convert the cleaned up handle back to the original one.
Diffstat (limited to 'protocols/nogaim.c')
-rw-r--r--protocols/nogaim.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index 7dc777ef..4b0b738b 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -98,7 +98,6 @@ void register_protocol (struct prpl *p)
protocols = g_list_append(protocols, p);
}
-
struct prpl *find_protocol(const char *name)
{
GList *gl;
@@ -1113,3 +1112,35 @@ void imc_rem_block( struct im_connection *ic, char *handle )
ic->acc->prpl->rem_deny( ic, handle );
}
+
+void imcb_clean_handle( struct im_connection *ic, char *handle )
+{
+ /* Accepts a handle and does whatever is necessary to make it
+ BitlBee-friendly. Currently this means removing everything
+ outside 33-127 (ASCII printable excl spaces), @ (only one
+ is allowed) and ! and : */
+ char out[strlen(handle)+1];
+ int s, d;
+
+ s = d = 0;
+ while( handle[s] )
+ {
+ if( handle[s] > ' ' && handle[s] != '!' && handle[s] != ':' &&
+ ( handle[s] & 0x80 ) == 0 )
+ {
+ if( handle[s] == '@' )
+ {
+ /* See if we got an @ already? */
+ out[d] = 0;
+ if( strchr( out, '@' ) )
+ continue;
+ }
+
+ out[d++] = handle[s];
+ }
+ s ++;
+ }
+ out[d] = handle[s];
+
+ strcpy( handle, out );
+}