# HG changeset patch # User Marcos Garc«ża Ochoa # Date 1225464671 0 # Node ID c204239bef48ee55371143dfd737c952a7891e88 # Parent 8d040d580a448fbf04e05cd2a0f2dc2253de19d9 Strip multiple leading mode characters from incoming nicknames. This patch adds the function irc_nick_skip_mode, which takes an IRC connection and nickname, and returns a pointer internal to the nickname representing the first non-mode-character of the nick. Apparently some IRC servers prepend more than one mode character to nicknames under some circumstances; the standard is pretty vague on the matter, and I can't see as how it hurts anything, so here goes. This patch was originally from Marcos Garc«ża Ochoa. Fixes #7416 committer: Ethan Blanton diff -r 8d040d580a44 -r c204239bef48 COPYRIGHT --- a/COPYRIGHT Fri Oct 31 09:32:41 2008 +0000 +++ b/COPYRIGHT Fri Oct 31 14:51:11 2008 +0000 @@ -287,6 +287,7 @@ Christopher O'Brien (siege) Peter O'Gorman Jon Oberheide +Marcos GarcĂ­a Ochoa Yusuke Odate Ruediger Oertel Gudmundur Bjarni Olafsson diff -r 8d040d580a44 -r c204239bef48 libpurple/protocols/irc/irc.c --- a/libpurple/protocols/irc/irc.c Fri Oct 31 09:32:41 2008 +0000 +++ b/libpurple/protocols/irc/irc.c Fri Oct 31 14:51:11 2008 +0000 @@ -62,8 +62,6 @@ PurplePlugin *_irc_plugin = NULL; -static const char *status_chars = "@+%&"; - static void irc_view_motd(PurplePluginAction *action) { PurpleConnection *gc = (PurpleConnection *) action->context; @@ -518,10 +516,7 @@ char *plain; const char *args[2]; - if (strchr(status_chars, *who) != NULL) - args[0] = who + 1; - else - args[0] = who; + args[0] = irc_nick_skip_mode(irc, who); purple_markup_html_to_xhtml(what, NULL, &plain); args[1] = plain; diff -r 8d040d580a44 -r c204239bef48 libpurple/protocols/irc/irc.h --- a/libpurple/protocols/irc/irc.h Fri Oct 31 09:32:41 2008 +0000 +++ b/libpurple/protocols/irc/irc.h Fri Oct 31 14:51:11 2008 +0000 @@ -109,6 +109,8 @@ char *irc_mirc2html(const char *string); char *irc_mirc2txt(const char *string); +const char *irc_nick_skip_mode(struct irc_conn *irc, const char *string); + gboolean irc_ischannel(const char *string); void irc_register_commands(void); diff -r 8d040d580a44 -r c204239bef48 libpurple/protocols/irc/parse.c --- a/libpurple/protocols/irc/parse.c Fri Oct 31 09:32:41 2008 +0000 +++ b/libpurple/protocols/irc/parse.c Fri Oct 31 14:51:11 2008 +0000 @@ -497,6 +497,19 @@ return result; } +const char *irc_nick_skip_mode(struct irc_conn *irc, const char *nick) +{ + static const char *default_modes = "@+%&"; + const char *mode_chars; + + mode_chars = irc->mode_chars ? irc->mode_chars : default_modes; + + while (strchr(mode_chars, *nick) != NULL) + nick++; + + return nick; +} + gboolean irc_ischannel(const char *string) { return (string[0] == '#' || string[0] == '&');