pidgin: ae6357a4: Strip multiple leading mode characters f...

elb at pidgin.im elb at pidgin.im
Fri Oct 31 10:55:32 EDT 2008


-----------------------------------------------------------------
Revision: ae6357a4d3665ba9693f4572a9b8ce4fc72392c8
Ancestor: 0e3190a56fd48629d009e9d8e53e65dd6f1b63e5
Author: magao at bigfoot.com
Date: 2008-10-31T14:51:11
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ae6357a4d3665ba9693f4572a9b8ce4fc72392c8

Modified files:
        COPYRIGHT libpurple/protocols/irc/irc.c
        libpurple/protocols/irc/irc.h
        libpurple/protocols/irc/parse.c

ChangeLog: 

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

-------------- next part --------------
============================================================
--- COPYRIGHT	4569660bdc3d558a2fc7477305ad35f4877f3bc2
+++ COPYRIGHT	696c95a22abae2444988ea9a853ad21107722ade
@@ -287,6 +287,7 @@ Jon Oberheide
 Christopher O'Brien (siege)
 Peter O'Gorman
 Jon Oberheide
+Marcos Garc?a Ochoa
 Yusuke Odate
 Ruediger Oertel
 Gudmundur Bjarni Olafsson
============================================================
--- libpurple/protocols/irc/irc.c	72232dd16f455e0ce3b0e0e11f7ae31041a40a48
+++ libpurple/protocols/irc/irc.c	0f7775728546224559660329274987e0a6b1aaf4
@@ -62,8 +62,6 @@ PurplePlugin *_irc_plugin = NULL;
 
 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 @@ static int irc_im_send(PurpleConnection 
 	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;
============================================================
--- libpurple/protocols/irc/irc.h	cc71f26aa63145049ea700ea00260dc22d78c0fd
+++ libpurple/protocols/irc/irc.h	a8868ca914d28d8cc42de7f923b89ac05c641554
@@ -109,6 +109,8 @@ char *irc_mirc2txt(const char *string);
 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);
============================================================
--- libpurple/protocols/irc/parse.c	5b7ebf223c97705e602213f69c8d23e3f8f8c254
+++ libpurple/protocols/irc/parse.c	4dc168b2028c151448ee2b22c41edc38b43eae41
@@ -497,6 +497,19 @@ char *irc_mirc2txt (const char *string)
         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] == '&');


More information about the Commits mailing list