From e3915d2f937a8e107a9c23277a648bc301debb95 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan <hypolite@mrpetovan.com>
Date: Wed, 16 Oct 2019 13:53:16 -0400
Subject: [PATCH] Prevent empty [url] label regular expression to break image
 insertion

---
 mod/item.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mod/item.php b/mod/item.php
index 77f23fee8d..7c8ebee4ab 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -230,7 +230,7 @@ function item_post(App $a) {
 	}
 
 	// Convert links with empty descriptions to links without an explicit description
-	$body = preg_replace('(\[url=(.*?)\]\[\/url\])ism', '[url]$1[/url]', $body);
+	$body = preg_replace('#\[url=([^\]]*?)\]\[/url\]#ism', '[url]$1[/url]', $body);
 
 	if (!empty($orig_post)) {
 		$str_group_allow   = $orig_post['allow_gid'];