From 1146fca2cd43f79b42ee8434932b8df35cfd1ae4 Mon Sep 17 00:00:00 2001
From: Michael
', $text);
$text = str_replace("\n", '
', $text);
// handle nested lists
@@ -1938,7 +1939,7 @@ class BBCode
: []
);
- $text = HTML::purify($text, $allowedIframeDomains);
+ $text = HTML::purify('
' . $text . '
', $allowedIframeDomains); DI::profiler()->stopRecording(); return trim($text); From eee65b31fd67067d13a2cff068b8c38fba145066 Mon Sep 17 00:00:00 2001 From: Michael' . $expectedHtml . '
', $actual); } public function dataBBCodesToMarkdown() diff --git a/tests/src/Factory/Api/Twitter/DirectMessageTest.php b/tests/src/Factory/Api/Twitter/DirectMessageTest.php index 216c4051f..62a9c43e5 100644 --- a/tests/src/Factory/Api/Twitter/DirectMessageTest.php +++ b/tests/src/Factory/Api/Twitter/DirectMessageTest.php @@ -67,7 +67,7 @@ class DirectMessageTest extends FixtureTest ->toArray(); self::assertEquals('item_title', $directMessage['title']); - self::assertEquals('item_body', $directMessage['text']); + self::assertEquals('item_body
', $directMessage['text']); } /** From 2a0ad0c4821846be89dabad29186affc074c92d0 Mon Sep 17 00:00:00 2001 From: MichaelTest text
', 'text' => '[size=xx-large]Test text[/size]', ], 'bug-2199-numeric-size' => [ - 'expectedHtml' => 'Test text', + 'expectedHtml' => 'Test text
', 'text' => '[size=24]Test text[/size]', ], 'bug-2199-diaspora-no-named-size' => [ - 'expectedHtml' => 'Test text', + 'expectedHtml' => 'Test text
', 'text' => '[size=xx-large]Test text[/size]', 'try_oembed' => false, // Triggers the diaspora compatible output 'simpleHtml' => BBCode::DIASPORA, ], 'bug-2199-diaspora-no-numeric-size' => [ - 'expectedHtml' => 'Test text', + 'expectedHtml' => 'Test text
', 'text' => '[size=24]Test text[/size]', 'try_oembed' => false, // Triggers the diaspora compatible output 'simpleHtml' => BBCode::DIASPORA, ], 'bug-7665-audio-tag' => [ - 'expectedHtml' => '', + 'expectedHtml' => '', 'text' => '[audio]http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3[/audio]', 'try_oembed' => true, ], 'bug-7808-code-lt' => [ - 'expectedHtml' => '<
',
+ 'expectedHtml' => '<
>
',
+ 'expectedHtml' => '>
&
',
+ 'expectedHtml' => '&
[test] Space
', 'text' => '[test] Space', ], 'task-8800-pre-spaces' => [ - 'expectedHtml' => ' Spaces', + 'expectedHtml' => 'Spaces
', 'text' => '[pre] Spaces[/pre]', ], 'bug-9611-purify-xss-nobb' => [ - 'expectedHTML' => 'dare to move your mouse here', + 'expectedHTML' => 'dare to move your mouse here
', 'text' => '[nobb]dare to move your mouse here[/nobb]' ], 'bug-9611-purify-xss-noparse' => [ - 'expectedHTML' => 'dare to move your mouse here', + 'expectedHTML' => 'dare to move your mouse here
', 'text' => '[noparse]dare to move your mouse here[/noparse]' ], 'bug-9611-purify-xss-attributes' => [ - 'expectedHTML' => 'dare to move your mouse here', + 'expectedHTML' => 'dare to move your mouse here
', 'text' => '[color="onmouseover=alert(0) style="]dare to move your mouse here[/color]' ], 'bug-9611-purify-attributes-correct' => [ - 'expectedHTML' => 'dare to move your mouse here', + 'expectedHTML' => 'dare to move your mouse here
', 'text' => '[color=FFFFFF]dare to move your mouse here[/color]' ], 'bug-9639-span-classes' => [ - 'expectedHTML' => 'Test', + 'expectedHTML' => 'Test
', 'text' => '[class=arbitrary classes]Test[/class]', ], 'bug-10772-duplicated-links' => [ - 'expectedHTML' => 'Jetzt wird mir klar, warum Kapitalisten jedes Mal durchdrehen wenn Marx und das Kapital ins Gespräch kommt. Soziopathen.Jetzt wird mir klar, warum Kapitalisten jedes Mal durchdrehen wenn Marx und das Kapital ins Gespräch kommt. Soziopathen.
Karl Marx - Die ursprüngliche Akkumulation
https://wohlstandfueralle.podigee.io/107-urspruengliche-akkumulation
#Podcast #Kapitalismus
', 'text' => '[emoji=https://fedi.underscore.world/emoji/custom/custom/heart_nb.png]:heart_nb:[/emoji]', ] ]; @@ -278,7 +278,7 @@ Karl Marx - Die ursprüngliche Akkumulation { $actual = BBCode::convert($text, $try_oembed, $simpleHtml, $forPlaintext); - self::assertEquals('
' . $expectedHtml . '
', $actual); + self::assertEquals($expectedHtml, $actual); } public function dataBBCodesToMarkdown() From dfaf3eee6bb6ec33eb58be5eeb4fea16acc955a5 Mon Sep 17 00:00:00 2001 From: Michael' . $text . '
', $allowedIframeDomains); + if (strpos($text, '') !== false || strpos($text, '
') !== false) { + $text = '' . $text . '
'; + } + + $text = HTML::purify($text, $allowedIframeDomains); DI::profiler()->stopRecording(); return trim($text); From d4aec5cbd3701cee0650b00d9ab1f761114944f2 Mon Sep 17 00:00:00 2001 From: MichaelTest text
', + 'expectedHtml' => 'Test text', 'text' => '[size=xx-large]Test text[/size]', ], 'bug-2199-numeric-size' => [ - 'expectedHtml' => 'Test text
', + 'expectedHtml' => 'Test text', 'text' => '[size=24]Test text[/size]', ], 'bug-2199-diaspora-no-named-size' => [ - 'expectedHtml' => 'Test text
', + 'expectedHtml' => 'Test text', 'text' => '[size=xx-large]Test text[/size]', 'try_oembed' => false, // Triggers the diaspora compatible output 'simpleHtml' => BBCode::DIASPORA, ], 'bug-2199-diaspora-no-numeric-size' => [ - 'expectedHtml' => 'Test text
', + 'expectedHtml' => 'Test text', 'text' => '[size=24]Test text[/size]', 'try_oembed' => false, // Triggers the diaspora compatible output 'simpleHtml' => BBCode::DIASPORA, ], 'bug-7665-audio-tag' => [ - 'expectedHtml' => '', + 'expectedHtml' => '', 'text' => '[audio]http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3[/audio]', 'try_oembed' => true, ], 'bug-7808-code-lt' => [ - 'expectedHtml' => '<
<
',
'text' => '[code]<[/code]',
],
'bug-7808-code-gt' => [
- 'expectedHtml' => '>
>
',
'text' => '[code]>[/code]',
],
'bug-7808-code-amp' => [
- 'expectedHtml' => '&
&
',
'text' => '[code]&[/code]',
],
'task-8800-pre-spaces-notag' => [
- 'expectedHtml' => '[test] Space
', + 'expectedHtml' => '[test] Space', 'text' => '[test] Space', ], 'task-8800-pre-spaces' => [ - 'expectedHtml' => 'Spaces
', + 'expectedHtml' => ' Spaces', 'text' => '[pre] Spaces[/pre]', ], 'bug-9611-purify-xss-nobb' => [ - 'expectedHTML' => 'dare to move your mouse here
', + 'expectedHTML' => 'dare to move your mouse here', 'text' => '[nobb]dare to move your mouse here[/nobb]' ], 'bug-9611-purify-xss-noparse' => [ - 'expectedHTML' => 'dare to move your mouse here
', + 'expectedHTML' => 'dare to move your mouse here', 'text' => '[noparse]dare to move your mouse here[/noparse]' ], 'bug-9611-purify-xss-attributes' => [ - 'expectedHTML' => 'dare to move your mouse here
', + 'expectedHTML' => 'dare to move your mouse here', 'text' => '[color="onmouseover=alert(0) style="]dare to move your mouse here[/color]' ], 'bug-9611-purify-attributes-correct' => [ - 'expectedHTML' => 'dare to move your mouse here
', + 'expectedHTML' => 'dare to move your mouse here', 'text' => '[color=FFFFFF]dare to move your mouse here[/color]' ], 'bug-9639-span-classes' => [ - 'expectedHTML' => 'Test
', + 'expectedHTML' => 'Test', 'text' => '[class=arbitrary classes]Test[/class]', ], 'bug-10772-duplicated-links' => [ - 'expectedHTML' => 'Jetzt wird mir klar, warum Kapitalisten jedes Mal durchdrehen wenn Marx und das Kapital ins Gespräch kommt. Soziopathen.
Karl Marx - Die ursprüngliche Akkumulation
https://wohlstandfueralle.podigee.io/107-urspruengliche-akkumulation
#Podcast #Kapitalismus
', + 'expectedHTML' => '', 'text' => '[emoji=https://fedi.underscore.world/emoji/custom/custom/heart_nb.png]:heart_nb:[/emoji]', ] ]; diff --git a/tests/src/Factory/Api/Twitter/DirectMessageTest.php b/tests/src/Factory/Api/Twitter/DirectMessageTest.php index 62a9c43e5..216c4051f 100644 --- a/tests/src/Factory/Api/Twitter/DirectMessageTest.php +++ b/tests/src/Factory/Api/Twitter/DirectMessageTest.php @@ -67,7 +67,7 @@ class DirectMessageTest extends FixtureTest ->toArray(); self::assertEquals('item_title', $directMessage['title']); - self::assertEquals('
item_body
', $directMessage['text']); + self::assertEquals('item_body', $directMessage['text']); } /** diff --git a/tests/src/Module/Api/Friendica/NotificationTest.php b/tests/src/Module/Api/Friendica/NotificationTest.php index e9eafc933..aaf702202 100644 --- a/tests/src/Module/Api/Friendica/NotificationTest.php +++ b/tests/src/Module/Api/Friendica/NotificationTest.php @@ -62,7 +62,7 @@ class NotificationTest extends ApiTest $assertXml = <<', $text); + $text = preg_replace("(\[h2\](.*?)\[\/h2\])ism", '
', $text); + $text = preg_replace("(\[h3\](.*?)\[\/h3\])ism", '
', $text); + $text = preg_replace("(\[h4\](.*?)\[\/h4\])ism", '
', $text); + $text = preg_replace("(\[h5\](.*?)\[\/h5\])ism", '
', $text); + $text = preg_replace("(\[h6\](.*?)\[\/h6\])ism", '
', $text); // Check for paragraph $text = preg_replace("(\[p\](.*?)\[\/p\])ism", '
$1
', $text); @@ -1466,27 +1466,27 @@ class BBCode ((strpos($text, "[/ol]") !== false) && (strpos($text, "[ol]") !== false)) || ((strpos($text, "[/ul]") !== false) && (strpos($text, "[ul]") !== false)) || ((strpos($text, "[/li]") !== false) && (strpos($text, "[li]") !== false))) && (++$endlessloop < 20)) { - $text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '', $text); + $text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '
', $text); + $text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '
', $text); + $text = preg_replace("/\[list=((?-i)i)\](.*?)\[\/list\]/ism", '
', $text); + $text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '
', $text); + $text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '
', $text); + $text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '
', $text); + $text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '
', $text); + $text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '
', $text); $text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '
', $text); - $text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '
', $text); + $text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '
', $text); - $text = str_replace('[hr]', '
', $text); if (!$for_plaintext) { $text = self::performWithEscapedTags($text, ['url', 'img', 'audio', 'video', 'youtube', 'vimeo', 'share', 'attachment', 'iframe', 'bookmark'], function ($text) { @@ -1520,7 +1520,7 @@ class BBCode } // Declare the format for [quote] layout - $QuoteLayout = '
$1'; + $QuoteLayout = '
$1
'; // Check for [quote] text // handle nested quotes diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index 4c1292344..82fdcc3cb 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -257,6 +257,14 @@ Karl Marx - Die ursprüngliche Akkumulation 'task-10886-deprecate-class' => [ 'expectedHTML' => '', 'text' => '[emoji=https://fedi.underscore.world/emoji/custom/custom/heart_nb.png]:heart_nb:[/emoji]', + ], + 'task-12900-multiple-paragraphs' => [ + 'expectedHTML' => '
This is a paragraph
with a line feed.
Second Chapter
', + 'text' => '[h1]Header[/h1][ul][*]One[*]Two[/ul]\n\nThis is a paragraph\nwith a line feed.\n\nSecond Chapter', + ], + 'task-12900-header-with-paragraphs' => [ + 'expectedHTML' => 'Some Chapter
', + 'text' => '[h1]Header[/h1]Some Chapter', ] ]; } From e55f38cc981ce1f8b80e9f9d9a61487f5395b5c3 Mon Sep 17 00:00:00 2001 From: MichaelThis is a paragraph
with a line feed.
Second Chapter
', + 'expectedHTML' => "This is a paragraph
with a line feed.
Second Chapter
", 'text' => '[h1]Header[/h1][ul][*]One[*]Two[/ul]\n\nThis is a paragraph\nwith a line feed.\n\nSecond Chapter', ], 'task-12900-header-with-paragraphs' => [ diff --git a/tests/src/Factory/Api/Twitter/StatusTest.php b/tests/src/Factory/Api/Twitter/StatusTest.php index 883894589..86b91deb3 100644 --- a/tests/src/Factory/Api/Twitter/StatusTest.php +++ b/tests/src/Factory/Api/Twitter/StatusTest.php @@ -64,7 +64,7 @@ class StatusTest extends FixtureTest ->toArray(); self::assertStringStartsWith('item_title', $status['text']); - self::assertStringStartsWith('perspiciatis impedit voluptatem', $status['friendica_html']);
}
/**
From 92a04baf62bcd5b4621408efcee06d893edba448 Mon Sep 17 00:00:00 2001
From: Michael This is a paragraph Second Chapter This is a paragraph Second Chapter Some ChapterHeader
with a line feed.Header
with a line feed.Header