From 5e3129307ee32f369b50d2663674fdff78391036 Mon Sep 17 00:00:00 2001 From: Ivan Shapovalov Date: Sun, 7 Jan 2018 21:34:50 +0100 Subject: [PATCH] parseMessage: allow . (dot), : (comma) and / (slash) in the nickname Allow . (dot), : (colon) and / (slash) in the nickname for compatibility with certain substandard IRC implementations (like the PSYC's built-in IRC gate). However, only allow those characters when we are sure that we are not taking a server hostname for a nick (otherwise any server hostname would get misparsed as a nick without !user@host). --- lib/parse_message.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/parse_message.js b/lib/parse_message.js index aa2b316d..00a8a2c9 100644 --- a/lib/parse_message.js +++ b/lib/parse_message.js @@ -23,7 +23,15 @@ module.exports = function parseMessage(line, stripColors) { if (match) { message.prefix = match[1]; line = line.replace(/^:[^ ]+ +/, ''); - match = message.prefix.match(/^([_a-zA-Z0-9\[\]\\`^{}|-]*)(!([^@]+)@(.*))?$/); + + // Allow . (dot), : (colon) and / (slash) in the nickname for compatibility + // with certain substandard IRC implementations (like the PSYC's built-in IRC gate). + // However, only allow those characters when we are sure that we are not taking + // a server hostname for a nick (otherwise any server hostname would get misparsed + // as a nick without !user@host). + + match = message.prefix.match(/^([_a-zA-Z0-9\[\]\\`^{}|-]*)(!([^@]+)@(.*))?$/) || + message.prefix.match(/^([_a-zA-Z0-9\[\]\\`^{}|:./-]*)(!([^@]+)@(.*))$/); if (match) { message.nick = match[1]; message.user = match[3];