Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Allow hostnames that do not contain a dot
Browse files Browse the repository at this point in the history
  • Loading branch information
Renegade334 committed May 9, 2015
1 parent 60bea2e commit ea3633f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ public function __construct()
$trailing = "(?: :?[^$null$crlf]*)";
$params = "(?P<params>$trailing?|(?:$middle{0,14}$trailing))";
$name = "[$letter$number](?:[$letter$number\\-]*[$letter$number])?";
$host = "$name(?:\\.(?:$name)*)+";
$host = "$name(?:\\.(?:$name)*)*";
$nick = "(?:[$letter$special][$letter$number$special-]*)";
$user = "(?:[^ $null$crlf@]+)";
$prefix = "(?:(?P<servername>$host)|(?:(?P<nick>$nick)(?:!(?P<user>$user))?(?:@(?P<host>$host))?))";
$prefix = "(?:(?:(?P<nick>$nick)(?:!(?P<user>$user))?(?:@(?P<host>$host))?)|(?P<servername>$host))";
$message = "(?P<prefix>:$prefix )?$command$params$crlf";
$this->message = "/^$message/SU";

Expand Down
19 changes: 18 additions & 1 deletion tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2768,7 +2768,7 @@ public function dataProviderTestParse()
),
),

// Hostnames/idents
// Hostname/ident patterns
array(
":[email protected] PRIVMSG target :message\r\n",
array(
Expand Down Expand Up @@ -2806,6 +2806,23 @@ public function dataProviderTestParse()
":nick!ident@- PRIVMSG target :message\r\n",
null,
),

array(
":nick!ident@localhost PRIVMSG target :message\r\n",
array(
'prefix' => ':nick!ident@localhost',
'nick' => 'nick',
'user' => 'ident',
'host' => 'localhost',
'command' => 'PRIVMSG',
'params' => array(
'all' => 'target :message',
'receivers' => 'target',
'text' => 'message',
),
'targets' => array('target'),
),
),
);

foreach ($data as $key => $value) {
Expand Down

0 comments on commit ea3633f

Please sign in to comment.