martynsmith/node-irc — Issue #55: NAMES command crashes client on InspIRCd-2.0 servers
Author: enunez
Created: 2011-11-04 06:01:50+00:00
State: open

The problem can be observed by just joining the client to any channel on an inspircd server (e.g., irc.alphachat.net). The problem is that InspIRCd is leaving a trailing space in the names reply, like so:

"353 somenick = #channel : nick1 somenick "

You're splitting on spaces, so you wind up with a blank nickname which you then attempt to parse as though it isn't -- match[1] bombs because it's null.

The solution is to just trim the list of nicknames. Here's the patch:

--- irc.js	2011-11-04 01:39:43.138346320 -0400
+++ irc.js.fixed	2011-11-04 01:41:10.478005694 -0400
@@ -196,7 +196,7 @@
break;
case "rpl_namreply":
var channel = self.chanData(message.args[2]);
- var users = message.args[3].split(/ +/);
+ var users = message.args[3].trim().split(/ +/);
if ( channel ) {
users.forEach(function (user) {
var match = user.match(/^(.)(.*)$/);