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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user