]> git.mxchange.org Git - friendica.git/commitdiff
Ensure null values aren't processed in Content\Text\Markdown::toBBCode
authorHypolite Petovan <hypolite@mrpetovan.com>
Fri, 2 Dec 2022 12:48:44 +0000 (07:48 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 3 Dec 2022 09:20:27 +0000 (04:20 -0500)
- Address part of https://github.com/friendica/friendica/issues/12011#issuecomment-1335124938

src/Content/Text/Markdown.php

index 3575c69a8b23ac93c6abf3473b5a2657998a71d7..53983113b27dfb46a85d597bab7ec45846850c6d 100644 (file)
@@ -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