From 38b29303d8cc576c9097c129fad57e21652f37b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 18 Jun 2013 00:13:24 +0200 Subject: [PATCH] Fix aliasing --- file/lib/system/command/CommandHandler.class.php | 8 +++----- file/lib/system/command/commands/PlainCommand.class.php | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/file/lib/system/command/CommandHandler.class.php b/file/lib/system/command/CommandHandler.class.php index a01e3c4..c1ad397 100644 --- a/file/lib/system/command/CommandHandler.class.php +++ b/file/lib/system/command/CommandHandler.class.php @@ -42,8 +42,10 @@ public function __construct($text, \chat\data\room\Room $room = null) { $aliases = self::getAliasMap(); foreach ($aliases as $search => $replace) { - $this->text = \wcf\system\Regex::compile('^'.preg_quote($search))->replace($this->text, $replace); + $this->text = \wcf\system\Regex::compile('^'.preg_quote(self::COMMAND_CHAR.$search).'( |$)')->replace($this->text, self::COMMAND_CHAR.$replace.' '); } + + $this->text = \wcf\system\Regex::compile('^//')->replace($this->text, '/plain '); } /** @@ -107,10 +109,6 @@ public function getParameters() { public function loadCommand() { $parts = explode(' ', StringUtil::substring($this->text, StringUtil::length(static::COMMAND_CHAR)), 2); - if ($this->isCommand($parts[0])) { - return new commands\PlainCommand($this); - } - $class = '\chat\system\command\commands\\'.ucfirst(strtolower($parts[0])).'Command'; if (!class_exists($class)) { throw new NotFoundException(); diff --git a/file/lib/system/command/commands/PlainCommand.class.php b/file/lib/system/command/commands/PlainCommand.class.php index 81913eb..0c08093 100644 --- a/file/lib/system/command/commands/PlainCommand.class.php +++ b/file/lib/system/command/commands/PlainCommand.class.php @@ -24,7 +24,7 @@ public function getType() { * @see \chat\system\command\ICommand::getMessage() */ public function getMessage() { - return \wcf\system\bbcode\PreParser::getInstance()->parse(\wcf\util\StringUtil::substring($this->commandHandler->getText(), 1), explode(',', \wcf\system\WCF::getSession()->getPermission('user.chat.allowedBBCodes'))); + return \wcf\system\bbcode\PreParser::getInstance()->parse(\chat\system\command\CommandHandler::COMMAND_CHAR.$this->commandHandler->getParameters(), explode(',', \wcf\system\WCF::getSession()->getPermission('user.chat.allowedBBCodes'))); } /**