From 81d500c271627fe605444b8c900f07375c609d98 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 20 Dec 2019 09:45:34 +0000 Subject: [PATCH] Fix optical glitch: Replace multiple newlines when replacing attachments --- src/Content/Text/BBCode.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 6d4c3418d0..e5622d14b4 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -398,15 +398,15 @@ class BBCode extends BaseObject */ public static function removeAttachment($body, $no_link_desc = false) { - return preg_replace_callback("/\[attachment (.*)\](.*?)\[\/attachment\]/ism", + return preg_replace_callback("/\s*\[attachment (.*)\](.*?)\[\/attachment\]\s*/ism", function ($match) use ($no_link_desc) { $attach_data = self::getAttachmentData($match[0]); if (empty($attach_data['url'])) { return $match[0]; } elseif (empty($attach_data['title']) || $no_link_desc) { - return '[url]' . $attach_data['url'] . "[/url]\n"; + return "\n[url]" . $attach_data['url'] . "[/url]\n"; } else { - return '[url=' . $attach_data['url'] . ']' . $attach_data['title'] . "[/url]\n"; + return "\n[url=" . $attach_data['url'] . ']' . $attach_data['title'] . "[/url]\n"; } }, $body); }