From 121ec67d0d08f4f8183fd2f8a8ef91ef92dad09c Mon Sep 17 00:00:00 2001 From: vrana Date: Thu, 21 Feb 2013 16:13:55 -0800 Subject: [PATCH] Avoid double escaping in Remarkup Summary: These all work with plain text. Fixes T2574. Test Plan: lang=remarkup > [[ a | ]] - [[ /a | ]] //a**b**c// Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2574 Differential Revision: https://secure.phabricator.com/D5060 --- src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php | 2 +- .../markup/rule/PhabricatorRemarkupRuleCountdown.php | 2 +- .../markup/rule/PhabricatorRemarkupRuleEmbedFile.php | 2 +- .../markup/rule/PhabricatorRemarkupRuleImageMacro.php | 2 +- src/infrastructure/markup/rule/PhabricatorRemarkupRuleMeme.php | 2 +- .../markup/rule/PhabricatorRemarkupRuleMention.php | 2 +- .../markup/rule/PhabricatorRemarkupRuleObjectHandle.php | 2 +- .../markup/rule/PhabricatorRemarkupRuleObjectName.php | 2 +- .../markup/rule/PhabricatorRemarkupRulePhriction.php | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php b/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php index 9b988c7e8f..48a2438c1b 100644 --- a/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php +++ b/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php @@ -19,7 +19,7 @@ final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule { // @{name | title} // @{type @ book : name @ context | title} - return $this->replaceHTML( + return preg_replace_callback( '/(?:^|\B)@{'. '(?:(?P[^:]+?):)?'. '(?P[^}|]+?)'. diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleCountdown.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleCountdown.php index 3356aed8e2..0fbe87ebfc 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleCountdown.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleCountdown.php @@ -8,7 +8,7 @@ final class PhabricatorRemarkupRuleCountdown extends PhutilRemarkupRule { const KEY_RULE_COUNTDOWN = 'rule.countdown'; public function apply($text) { - return $this->replaceHTML( + return preg_replace_callback( "@\B{C(\d+)}\B@", array($this, 'markupCountdown'), $text); diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleEmbedFile.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleEmbedFile.php index e7c25dd1fe..9ef0ac8ad9 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleEmbedFile.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleEmbedFile.php @@ -10,7 +10,7 @@ final class PhabricatorRemarkupRuleEmbedFile const KEY_EMBED_FILE_PHIDS = 'phabricator.embedded-file-phids'; public function apply($text) { - return $this->replaceHTML( + return preg_replace_callback( "@{F(\d+)([^}]+?)?}@", array($this, 'markupEmbedFile'), $text); diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleImageMacro.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleImageMacro.php index 2bf0d89fcf..7ad83ebc58 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleImageMacro.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleImageMacro.php @@ -9,7 +9,7 @@ final class PhabricatorRemarkupRuleImageMacro private $images; public function apply($text) { - return $this->replaceHTML( + return preg_replace_callback( '@^([a-zA-Z0-9:_\-]+)$@m', array($this, 'markupImageMacro'), $text); diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMeme.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMeme.php index b569eb60ac..1254d044ad 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMeme.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMeme.php @@ -9,7 +9,7 @@ final class PhabricatorRemarkupRuleMeme private $images; public function apply($text) { - return $this->replaceHTML( + return preg_replace_callback( '@{meme,([^}]+)}$@m', array($this, 'markupMeme'), $text); diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMention.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMention.php index b2a98fc9af..7f05ff95a1 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMention.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleMention.php @@ -21,7 +21,7 @@ final class PhabricatorRemarkupRuleMention const REGEX = '/(?replaceHTML( + return preg_replace_callback( self::REGEX, array($this, 'markupMention'), $text); diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectHandle.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectHandle.php index 8aa082b621..c47681a7f7 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectHandle.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectHandle.php @@ -13,7 +13,7 @@ abstract class PhabricatorRemarkupRuleObjectHandle public function apply($text) { $prefix = $this->getObjectNamePrefix(); - return $this->replaceHTML( + return preg_replace_callback( "@\B{{$prefix}(\d+)}\B@", array($this, 'markupObjectHandle'), $text); diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectName.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectName.php index 859bebdc74..b81c37cc2f 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectName.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRuleObjectName.php @@ -15,7 +15,7 @@ abstract class PhabricatorRemarkupRuleObjectName public function apply($text) { $prefix = $this->getObjectNamePrefix(); $id = $this->getObjectIDPattern(); - return $this->replaceHTML( + return preg_replace_callback( "@\b({$prefix})({$id})(?:#([-\w\d]+))?\b@", array($this, 'markupObjectNameLink'), $text); diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRulePhriction.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRulePhriction.php index 56a84d0d75..e42c680a63 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRulePhriction.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRulePhriction.php @@ -7,7 +7,7 @@ final class PhabricatorRemarkupRulePhriction extends PhutilRemarkupRule { public function apply($text) { - return $this->replaceHTML( + return preg_replace_callback( '@\B\\[\\[([^|\\]]+)(?:\\|([^\\]]+))?\\]\\]\B@U', array($this, 'markupDocumentLink'), $text);