Keep spaces after non-tags in Content\BBCode::convert

- Added test case
This commit is contained in:
Hypolite Petovan 2020-06-23 07:52:38 -04:00
parent 4e5c3157fe
commit 251a3791dd
2 changed files with 8 additions and 4 deletions

View file

@ -1299,9 +1299,9 @@ class BBCode
// Remove the abstract element. It is a non visible element. // Remove the abstract element. It is a non visible element.
$text = self::stripAbstract($text); $text = self::stripAbstract($text);
// Move all spaces out of the tags // Move new lines outside of tags
$text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $text); $text = preg_replace("#\[(\w*)](\n*)#ism", '$2[$1]', $text);
$text = preg_replace("/(\s*)\[\/(\w*)\]/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 // 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 // large data sizes. Stash them away while we do bbcode conversion, and then put them back

View file

@ -236,7 +236,11 @@ class BBCodeTest extends MockedTest
'bug-7808-code-amp' => [ 'bug-7808-code-amp' => [
'expectedHtml' => '<code>&amp;</code>', 'expectedHtml' => '<code>&amp;</code>',
'text' => '[code]&[/code]', 'text' => '[code]&[/code]',
] ],
'task-8800-pre-spaces-notag' => [
'expectedHtml' => '[test] Space',
'text' => '[test] Space',
],
]; ];
} }