From 5183bf3c49812586c3e406d2c232b533e6515b4e Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 12 Aug 2014 14:07:23 -0700 Subject: [PATCH] Detect macros more strictly in bot handler Summary: Fixes T5863. Like Remarkup, only identify macros if the entire chat line is the macro. Test Plan: https://secure.phabricator.com/chatlog/channel/6/?at=158229 Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5863 Differential Revision: https://secure.phabricator.com/D10242 --- .../daemon/bot/handler/PhabricatorBotMacroHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/infrastructure/daemon/bot/handler/PhabricatorBotMacroHandler.php b/src/infrastructure/daemon/bot/handler/PhabricatorBotMacroHandler.php index 10bbbd48b9..9f7a4e6625 100644 --- a/src/infrastructure/daemon/bot/handler/PhabricatorBotMacroHandler.php +++ b/src/infrastructure/daemon/bot/handler/PhabricatorBotMacroHandler.php @@ -31,7 +31,7 @@ final class PhabricatorBotMacroHandler extends PhabricatorBotHandler { foreach ($macros as $macro_name => $macro) { $regexp[] = preg_quote($macro_name, '/'); } - $regexp = '/('.implode('|', $regexp).')/'; + $regexp = '/^('.implode('|', $regexp).')\z/'; $this->macros = $macros; $this->regexp = $regexp; @@ -49,7 +49,7 @@ final class PhabricatorBotMacroHandler extends PhabricatorBotHandler { $message_body = $message->getBody(); $matches = null; - if (!preg_match($this->regexp, $message_body, $matches)) { + if (!preg_match($this->regexp, trim($message_body), $matches)) { return; }