From: Hypolite Petovan Date: Fri, 2 Dec 2022 12:48:44 +0000 (-0500) Subject: Ensure null values aren't processed in Content\Text\Markdown::toBBCode X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3b3192933d51d7d6242639dcdb021a90a86f5084;p=friendica.git Ensure null values aren't processed in Content\Text\Markdown::toBBCode - Address part of https://github.com/friendica/friendica/issues/12011#issuecomment-1335124938 --- diff --git a/src/Content/Text/Markdown.php b/src/Content/Text/Markdown.php index 3575c69a8b..53983113b2 100644 --- a/src/Content/Text/Markdown.php +++ b/src/Content/Text/Markdown.php @@ -21,6 +21,8 @@ namespace Friendica\Content\Text; +use Friendica\Core\Logger; +use Friendica\Core\System; use Friendica\DI; use Friendica\Model\Contact; @@ -106,8 +108,18 @@ class Markdown * So we'll use that to convert to HTML, then convert the HTML back to bbcode, * and then clean up a few Diaspora specific constructs. */ - public static function toBBCode($s) + public static function toBBCode($s): string { + // @TODO Temporary until we find the source of the null value to finally set the correct type-hint + if (is_null($s)) { + Logger::warning('Received null value', ['callstack' => System::callstack()]); + return ''; + } + + if (!$s) { + return $s; + } + DI::profiler()->startRecording('rendering'); // The parser cannot handle paragraphs correctly