From 5fca20d34b62947dbe656b48ba646c2cb4ace554 Mon Sep 17 00:00:00 2001 From: Marc Pina Date: Mon, 7 Mar 2016 00:31:51 +0100 Subject: [PATCH 1/5] Allowing ~ character in nicks. It is allowed in some networks. --- src/Parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parser.php b/src/Parser.php index 8c29978..0fb1de7 100755 --- a/src/Parser.php +++ b/src/Parser.php @@ -207,7 +207,7 @@ public function __construct() $trailing = "(?: :?[^$null$crlf]*)"; $params = "(?P$trailing?|(?:$middle{0,14}$trailing))"; $host = '[^ ]+'; - $nick = "(?:[\\*$letter$special][$letter$number$special-]*)"; + $nick = "(?:[\\*$letter$special][$letter$number$special-~]*)"; $user = "(?:[^ $null$crlf@]+)"; $prefix = "(?:(?:(?P$nick)(?:!(?P$user))?(?:@(?P$host))?)|(?P$host))"; $message = "(?P:$prefix )?$command$params$crlf"; From 92d321b0f4d05c14ca85f729571a324b73b00c3d Mon Sep 17 00:00:00 2001 From: Marc Pina Date: Mon, 7 Mar 2016 00:50:13 +0100 Subject: [PATCH 2/5] Fixing tests. --- src/Parser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Parser.php b/src/Parser.php index 0fb1de7..6cd57b7 100755 --- a/src/Parser.php +++ b/src/Parser.php @@ -199,7 +199,7 @@ public function __construct() $crlf = "\r\n"; $letter = 'a-zA-Z'; $number = '0-9'; - $special = preg_quote('[]\`_^{|}'); + $special = preg_quote('[]\`_^{|}~'); $null = '\\x00'; $command = "(?P[$letter]+|[$number]{3})"; $middle = "(?: [^ $null$crlf:][^ $null$crlf]*)"; @@ -207,7 +207,7 @@ public function __construct() $trailing = "(?: :?[^$null$crlf]*)"; $params = "(?P$trailing?|(?:$middle{0,14}$trailing))"; $host = '[^ ]+'; - $nick = "(?:[\\*$letter$special][$letter$number$special-~]*)"; + $nick = "(?:[\\*$letter$special][$letter$number$special-]*)"; $user = "(?:[^ $null$crlf@]+)"; $prefix = "(?:(?:(?P$nick)(?:!(?P$user))?(?:@(?P$host))?)|(?P$host))"; $message = "(?P:$prefix )?$command$params$crlf"; From 04b35a3595435c79372186531b51ab4f87c7a0f1 Mon Sep 17 00:00:00 2001 From: Marc Pina Date: Mon, 7 Mar 2016 15:26:43 +0100 Subject: [PATCH 3/5] Adding test to check nicks with ~ --- tests/ParserTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 30838e3..f1abc8c 100755 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -176,6 +176,19 @@ public function dataProviderTestParse() 'targets' => array('Wiz_'), ), ), + + // Nick with ~ character allowed + array( + "NICK :Incredible~\r\n", + array( + 'command' => 'NICK', + 'params' => array( + 'nickname' => 'Incredible~', + 'all' => ':Incredible~', + ), + 'targets' => array('Incredible~'), + ), + ), array( "NICK Wiz :1\r\n", From 1d526006955a6d5ac3988b10231b3f791c822090 Mon Sep 17 00:00:00 2001 From: Marc Pina Date: Mon, 7 Mar 2016 15:31:15 +0100 Subject: [PATCH 4/5] Adding test to check nicks with ~ on PRIVMSG --- tests/ParserTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 30838e3..093ad4e 100755 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -1165,6 +1165,22 @@ public function dataProviderTestParse() ), ), + // Test nicks with ~ + array( + ":Angel~ PRIVMSG Wiz~ :Hello are you receiving this message ?\r\n", + array( + 'prefix' => ':Angel~', + 'nick' => 'Angel~', + 'command' => 'PRIVMSG', + 'params' => array( + 'receivers' => 'Wiz~', + 'text' => 'Hello are you receiving this message ?', + 'all' => 'Wiz~ :Hello are you receiving this message ?', + ), + 'targets' => array('Wiz~'), + ), + ), + array( "PRIVMSG Angel :yes I'm receiving it !receiving it !'u>(768u+1n) .br\r\n", array( From 6c9ef0107a184cc83382ed3155c6534693d0629e Mon Sep 17 00:00:00 2001 From: Marc Pina Date: Mon, 7 Mar 2016 15:32:31 +0100 Subject: [PATCH 5/5] Adding test to check nicks with ~ on MODE message. --- tests/ParserTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 093ad4e..e2d89cf 100755 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -525,6 +525,22 @@ public function dataProviderTestParse() ), ), + // Testing nicks with ~ + array( + "MODE #Finnish +o :Kilroy~\r\n", + array( + 'command' => 'MODE', + 'params' => array( + 'channel' => '#Finnish', + 'mode' => '+o', + 'params' => 'Kilroy~', + 'user' => 'Kilroy~', + 'all' => '#Finnish +o :Kilroy~', + ), + 'targets' => array('#Finnish'), + ), + ), + array( "MODE #Finnish +v :Wiz\r\n", array(