changeset 24296:c204239bef48

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 <elb@pidgin.im>
author Marcos García Ochoa <magao@bigfoot.com>
date Fri, 31 Oct 2008 14:51:11 +0000
parents 8d040d580a44
children 44be22ce7970
files COPYRIGHT libpurple/protocols/irc/irc.c libpurple/protocols/irc/irc.h libpurple/protocols/irc/parse.c
diffstat 4 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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;
--- 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);
--- 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] == '&');