From f9165fbaf0cc1d3459c78a40d1f1230754da136b Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 15 Oct 2021 11:36:40 -0400 Subject: [PATCH 1/2] Decode HTML entities in code blocks in HTML::toBBCode - Replace PHP_EOL uses with the more common \n --- src/Content/Text/HTML.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index 0e117a220..e1caca48a 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -386,7 +386,7 @@ class HTML $prefix = '[code=' . $matches[1] . ']'; } - return $prefix . PHP_EOL . trim($matches[2]) . PHP_EOL . '[/code]'; + return $prefix . "\n" . html_entity_decode($matches[2]) . "\n" . '[/code]'; }, $message ); From 5feb80397fc3b274c03be7e2aa7cec1ad421dc54 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 15 Oct 2021 11:37:21 -0400 Subject: [PATCH 2/2] Added test for code blocks containing HTML entities in HTMLTest::toBBCode --- tests/src/Content/Text/HTMLTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/src/Content/Text/HTMLTest.php b/tests/src/Content/Text/HTMLTest.php index bf5e676a9..fb2b95740 100644 --- a/tests/src/Content/Text/HTMLTest.php +++ b/tests/src/Content/Text/HTMLTest.php @@ -84,6 +84,16 @@ class HTMLTest extends MockedTest 'expectedBBCode' => " I don't understand tests", 'html' => "<big rant here> I don't understand tests", ], + 'bug-10877-code-entities' => [ + 'expectedBBCode' => "Now playing +[code] +echo \"main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6));}\" | gcc -o a.out -x c - 2> /dev/null +./a.out | aplay -q 2> /dev/null +[/code] +its surprisingly good", + 'html' => "

Now playing

echo "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6));}" | gcc -o a.out -x c - 2> /dev/null
+./a.out | aplay -q 2> /dev/null

its surprisingly good

", + ], ]; }