]> git.mxchange.org Git - friendica.git/commitdiff
Keep spaces after non-tags in Content\BBCode::convert
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 23 Jun 2020 11:52:38 +0000 (07:52 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 23 Jun 2020 11:52:38 +0000 (07:52 -0400)
- Added test case

src/Content/Text/BBCode.php
tests/src/Content/Text/BBCodeTest.php

index 1cd8e438cd310a1f3656c17fb5f4ef14c6d55628..95484de720c5a31331ad3f614e5f8463e4d4ac43 100644 (file)
@@ -1299,9 +1299,9 @@ class BBCode
                                // Remove the abstract element. It is a non visible element.
                                $text = self::stripAbstract($text);
 
-                               // Move all spaces out of the tags
-                               $text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $text);
-                               $text = preg_replace("/(\s*)\[\/(\w*)\]/ism", '[/$2]$1', $text);
+                               // Move new lines outside of tags
+                               $text = preg_replace("#\[(\w*)](\n*)#ism", '$2[$1]', $text);
+                               $text = preg_replace("#(\n*)\[/(\w*)]#ism", '[/$2]$1', $text);
 
                                // Extract the private images which use data urls since preg has issues with
                                // large data sizes. Stash them away while we do bbcode conversion, and then put them back
index 35dff87d9fc7b04fbb2278aaa5ac6d7225d957c8..82e2853e7145a5be3f0e6cdf85aedd2eacc4801e 100644 (file)
@@ -236,7 +236,11 @@ class BBCodeTest extends MockedTest
                        'bug-7808-code-amp' => [
                                'expectedHtml' => '<code>&amp;</code>',
                                'text' => '[code]&[/code]',
-                       ]
+                       ],
+                       'task-8800-pre-spaces-notag' => [
+                               'expectedHtml' => '[test] Space',
+                               'text' => '[test] Space',
+                       ],
                ];
        }