@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PhutilRemarkupHexColorCodeRule: Do not assume that parameter is a string

Summary:
Check type before potentially mangling HTML in a PhutilSafeHTML element.
For now, do not try to apply this renderer when not dealing with a plain string.

Closes T15802

Test Plan: After deleting the corresponding MarkupCache via `DELETE FROM phabricator_cache.cache_markupcache WHERE cacheData LIKE "%whatever description on the page%";` check the description of a page, e.g. of `/config/edit/security.require-https/` or `/config/edit/storage.default-namespace/`.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15802

Differential Revision: https://we.phorge.it/D25605

+13 -4
+7 -4
src/infrastructure/markup/markuprule/PhutilRemarkupHexColorCodeRule.php
··· 9 9 10 10 public function apply($text) { 11 11 // Match {#FFFFFF} 12 - return preg_replace_callback( 13 - '@\B\{(#([0-9a-fA-F]{3}){1,2})\}@', 14 - array($this, 'markupHexColorCodedText'), 15 - $text); 12 + if (is_string($text)) { 13 + return preg_replace_callback( 14 + '@\B\{(#([0-9a-fA-F]{3}){1,2})\}@', 15 + array($this, 'markupHexColorCodedText'), 16 + $text); 17 + } 18 + return $text; 16 19 } 17 20 18 21 protected function contrastingColor($color_code) {
+6
src/infrastructure/markup/markuprule/PhutilRemarkupRule.php
··· 18 18 return 500.0; 19 19 } 20 20 21 + /** 22 + * Check input whether to apply RemarkupRule. If true, apply formatting. 23 + * @param string|PhutilSafeHTML String to check and potentially format. 24 + * @return string|PhutilSafeHTML Unchanged input if no match, or input after 25 + * matching the formatting rule and applying the formatting. 26 + */ 21 27 abstract public function apply($text); 22 28 23 29 public function getPostprocessKey() {