From 4dc49f7a93e4aca00d081f62a3d43f7c853296a1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 21 Feb 2013 16:36:54 -0800 Subject: [PATCH] Unparse/escape macros with commas, etc., correctly Summary: Fixes T2574. Test Plan: {F33501} Reviewers: vrana Reviewed By: vrana CC: aran Maniphest Tasks: T2574 Differential Revision: https://secure.phabricator.com/D5062 --- .../PhabricatorMacroMemeDialogController.php | 10 +++++++++- .../markup/rule/PhabricatorRemarkupRuleMeme.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php b/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php index df07660b3d..9bb82f9926 100644 --- a/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php +++ b/src/applications/macro/controller/PhabricatorMacroMemeDialogController.php @@ -28,8 +28,16 @@ final class PhabricatorMacroMemeDialogController } if (!$errors) { + $options = new PhutilSimpleOptions(); + $data = array( + 'src' => $name, + 'above' => $above, + 'below' => $below, + ); + $string = $options->unparse($data, $escape = '}'); + $result = array( - 'text' => "{meme, src={$name}, above={$above}, below={$below}}", + 'text' => "{meme, {$string}}", ); return id(new AphrontAjaxResponse())->setContent($result); } diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMeme.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMeme.php index 1254d044ad..665fbf7a95 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMeme.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMeme.php @@ -10,7 +10,7 @@ final class PhabricatorRemarkupRuleMeme public function apply($text) { return preg_replace_callback( - '@{meme,([^}]+)}$@m', + '@{meme,((?:[^}\\\\]+|\\\\.)+)}$@m', array($this, 'markupMeme'), $text); }