diff --git a/src/infrastructure/markup/markuprule/PhutilRemarkupHexColorCodeRule.php b/src/infrastructure/markup/markuprule/PhutilRemarkupHexColorCodeRule.php --- a/src/infrastructure/markup/markuprule/PhutilRemarkupHexColorCodeRule.php +++ b/src/infrastructure/markup/markuprule/PhutilRemarkupHexColorCodeRule.php @@ -9,10 +9,13 @@ public function apply($text) { // Match {#FFFFFF} - return preg_replace_callback( - '@\B\{(#([0-9a-fA-F]{3}){1,2})\}@', - array($this, 'markupHexColorCodedText'), - $text); + if (is_string($text)) { + return preg_replace_callback( + '@\B\{(#([0-9a-fA-F]{3}){1,2})\}@', + array($this, 'markupHexColorCodedText'), + $text); + } + return $text; } protected function contrastingColor($color_code) { diff --git a/src/infrastructure/markup/markuprule/PhutilRemarkupRule.php b/src/infrastructure/markup/markuprule/PhutilRemarkupRule.php --- a/src/infrastructure/markup/markuprule/PhutilRemarkupRule.php +++ b/src/infrastructure/markup/markuprule/PhutilRemarkupRule.php @@ -18,6 +18,12 @@ return 500.0; } + /** + * Check input whether to apply RemarkupRule. If true, apply formatting. + * @param string|PhutilSafeHTML String to check and potentially format. + * @return string|PhutilSafeHTML Unchanged input if no match, or input after + * matching the formatting rule and applying the formatting. + */ abstract public function apply($text); public function getPostprocessKey() {