mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
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:
parent
c443913c0b
commit
5183bf3c49
1 changed files with 2 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue