martynsmith/node-irc — pull request #143 by n0valyfe (2013-02-01 12:20:36+00:00)
Title: Fixed crash with janus

In some cases message.nick is undefined when using janus. It appears it can't be parsed properly because janus allows non RFC characters in nicknames to distinguish networks. Such as "X/alpha". This caused a message object to look like:

```
{ line: ':Someone/gig!~quassel@hostname.com JOIN #channel',
prefix: 'Someone/gig!~quassel@hostname.com JOIN #channel',
server: 'Someone/gig!~quassel@hostname.com JOIN #channel',
command: 'JOIN',
rawCommand: 'JOIN',
commandType: 'normal',
args: [ '#channel' ] }
```

This means undefined is passed to events such as join and part, which can cause a crash. I've patched the regex so it can handle parsing nicknames with / in them.

```
{ line: ':Someone/gig!~quassel@hostname.com JOIN #channel',
prefix: 'Someone/gig!~quassel@hostname.com JOIN #channel',
nick: 'Someone/gig',
user: '~quassel',
host: 'chostname.com',
command: 'JOIN',
rawCommand: 'JOIN',
commandType: 'normal',
args: [ '#channel' ] }
```

Although it may need to be revised all together as a delimiter can be any character but " !" (I think, struggling to find documentation on it), so in theory a network with any random character could cause a crash. In this scenario `message.prefix.match(/^([^ !]+)(!([^@]+)@(.*))?$/)` would do the job.