--- a/slashexec/slashexec.c Sun Aug 03 09:15:34 2008 -0400
+++ b/slashexec/slashexec.c Sun Aug 03 20:55:53 2008 -0400
@@ -96,6 +96,25 @@
+se_strdelimit(gchar *string, gchar newdelim) +{ /* This function borrowed and tweaked from glib to suit my purposes */ + /* these are the decimal representations of the ascii control characters that + * we need to remove to prevent bad behavior, such as XMPP disconnects */ + gchar delimiters[] = { 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; + g_return_val_if_fail(string !=NULL, NULL); + for(c = string; *c; c = g_utf8_next_char(c)) + if(strchr(delimiters, *c)) se_do_action(PurpleConversation *conv, gchar *args, gboolean send)
@@ -244,6 +263,18 @@
purple_debug_info("slashexec", "Command stdout: %s\n", cmd_stdout);
+ if(!g_utf8_validate(cmd_stdout, -1, NULL)) { + purple_debug_error("slashexec", "Output failed UTF-8 verification!\n"); + cmd_stdout = se_strdelimit(cmd_stdout, ' '); + g_strstrip(cmd_stdout); + purple_debug_info("slashexec", "Sanitized command stdout: %s\n", cmd_stdout); switch(purple_conversation_get_type(conv)) {
case PURPLE_CONV_TYPE_IM:
purple_conv_im_send(PURPLE_CONV_IM(conv), cmd_stdout);