1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +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:
epriestley 2014-08-12 14:07:23 -07:00
parent c443913c0b
commit 5183bf3c49

View file

@ -31,7 +31,7 @@ final class PhabricatorBotMacroHandler extends PhabricatorBotHandler {
foreach ($macros as $macro_name => $macro) { foreach ($macros as $macro_name => $macro) {
$regexp[] = preg_quote($macro_name, '/'); $regexp[] = preg_quote($macro_name, '/');
} }
$regexp = '/('.implode('|', $regexp).')/'; $regexp = '/^('.implode('|', $regexp).')\z/';
$this->macros = $macros; $this->macros = $macros;
$this->regexp = $regexp; $this->regexp = $regexp;
@ -49,7 +49,7 @@ final class PhabricatorBotMacroHandler extends PhabricatorBotHandler {
$message_body = $message->getBody(); $message_body = $message->getBody();
$matches = null; $matches = null;
if (!preg_match($this->regexp, $message_body, $matches)) { if (!preg_match($this->regexp, trim($message_body), $matches)) {
return; return;
} }