From cefb8a50f24009a3a7d5f8e3a1f686788efa9b55 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Wed, 18 Mar 2009 18:03:47 +0100 Subject: [PATCH] Replace WeeChat color codes by "?" in incoming IRC messages (bug #25862) --- src/plugins/irc/irc-color.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c index 6e1fe3d4c..044e78081 100644 --- a/src/plugins/irc/irc-color.c +++ b/src/plugins/irc/irc-color.c @@ -54,12 +54,13 @@ char *irc_color_to_weechat[IRC_NUM_COLORS] = * irc_color_decode: replace IRC colors by WeeChat colors * if keep_colors == 0: remove any color/style in message * otherwise: keep colors -x * Note: after use, string returned has to be free() + * Note: after use, string returned has to be free() */ char * irc_color_decode (const char *string, int keep_colors) { + char *string_without_weechat_colors; unsigned char *out, *ptr_string; int out_length, length, out_pos; char str_fg[3], str_bg[3], str_color[128]; @@ -75,7 +76,9 @@ irc_color_decode (const char *string, int keep_colors) italic = 0; underline = 0; - ptr_string = (unsigned char *)string; + string_without_weechat_colors = weechat_string_remove_color (string, "?"); + ptr_string = (string_without_weechat_colors) ? + (unsigned char *)string_without_weechat_colors : (unsigned char *)string; out[0] = '\0'; while (ptr_string && ptr_string[0]) { @@ -193,6 +196,9 @@ irc_color_decode (const char *string, int keep_colors) } } + if (string_without_weechat_colors) + free (string_without_weechat_colors); + return (char *)out; }