From: Michael Date: Sun, 29 Dec 2019 21:01:38 +0000 (+0000) Subject: Markdown: Protect some more elements from markdown parsing X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dbd9e940c839cb3d1cc06a61ee8a13039b04f391;p=friendica-addons.git Markdown: Protect some more elements from markdown parsing --- diff --git a/markdown/markdown.php b/markdown/markdown.php index bd0e022c..0f667373 100644 --- a/markdown/markdown.php +++ b/markdown/markdown.php @@ -50,11 +50,11 @@ function markdown_post_local_start(App $a, &$request) { } // Elements that shouldn't be parsed - $elements = ['code', 'noparse', 'nobb', 'pre']; + $elements = ['code', 'noparse', 'nobb', 'pre', 'share', 'url', 'img']; foreach ($elements as $element) { - $request['body'] = preg_replace_callback("/\[" . $element . "\](.*?)\[\/" . $element . "\]/ism", - function ($match) use ($element) { - return '[base64' . $element . ']' . base64_encode($match[1]) . '[/base64' . $element . ']'; + $request['body'] = preg_replace_callback("/\[" . $element . "(.*?)\](.*?)\[\/" . $element . "\]/ism", + function ($match) use ($element) { + return '[' . $element . '-b64' . base64_encode($match[1]) . ']' . base64_encode($match[2]) . '[/b64-' . $element . ']'; }, $request['body'] ); @@ -63,9 +63,9 @@ function markdown_post_local_start(App $a, &$request) { $request['body'] = Markdown::toBBCode($request['body']); foreach (array_reverse($elements) as $element) { - $request['body'] = preg_replace_callback("/\[base64" . $element . "\](.*?)\[\/base64" . $element . "\]/ism", - function ($match) use ($element) { - return '[' . $element . ']' . base64_decode($match[1]) . '[/' . $element . ']'; + $request['body'] = preg_replace_callback("/\[" . $element . "-b64(.*?)\](.*?)\[\/b64-" . $element . "\]/ism", + function ($match) use ($element) { + return '[' . $element . base64_decode($match[1]) . ']' . base64_decode($match[2]) . '[/' . $element . ']'; }, $request['body'] );