]> git.mxchange.org Git - friendica.git/commitdiff
Increase specificity of [url][img] capture regex in BBCode::getAttachedData
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 10 Feb 2020 03:19:21 +0000 (22:19 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 10 Feb 2020 03:19:21 +0000 (22:19 -0500)
- Prevents it from over capturing when there's a [url] tag before the image

src/Content/Text/BBCode.php

index f8b9fb29851d3df13abe2139a87c59d00cd43fc2..3c6b7062de206ce2bfaceca3627d39956ea51a1b 100644 (file)
@@ -273,7 +273,7 @@ class BBCode
                        $body = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $body);
                        $post['text'] = $body;
 
-                       if (preg_match_all("(\[url=(.*?)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\])ism", $body, $pictures, PREG_SET_ORDER)) {
+                       if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img\]([^\[]+?)\[/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
                                if ((count($pictures) == 1) && !$has_title) {
                                        if (!empty($item['object-type']) && ($item['object-type'] == Activity\ObjectType::IMAGE)) {
                                                // Replace the preview picture with the real picture