From aa6497c28151f013778a2e3fe11fa40509c864d3 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 5 Sep 2019 05:14:43 +0000 Subject: [PATCH 1/2] Issue 2199: Diaspora doesn't interpret size elements --- src/Content/Text/BBCode.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index f5b869979..65d037b83 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1404,8 +1404,14 @@ class BBCode extends BaseObject // Check for sized text // [size=50] --> font-size: 50px (with the unit). - $text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism", "$2", $text); - $text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism", "$2", $text); + if ($simple_html != 3) { + $text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism", "$2", $text); + $text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism", "$2", $text); + } else { + // Issue 2199: Diaspora doesn't interpret the construct above, nor the or element + $text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism", "$2", $text); + } + // Check for centered text $text = preg_replace("(\[center\](.*?)\[\/center\])ism", "
$1
", $text); From ba2e57e84a6e1705bf3558af66788a619bfe2be7 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 5 Sep 2019 20:37:16 +0000 Subject: [PATCH 2/2] Added tests --- tests/src/Content/Text/BBCodeTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index 899f32764..3d8beb393 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -176,6 +176,28 @@ class BBCodeTest extends MockedTest [*]http://example.com/ [/ul]', ], + 'bug-2199-named-size' => [ + 'expectedHtml' => 'Test text', + 'text' => '[size=xx-large]Test text[/size]', + 'simpleHtml' => 0, + ], + 'bug-2199-numeric-size' => [ + 'expectedHtml' => 'Test text', + 'text' => '[size=24]Test text[/size]', + 'simpleHtml' => 0, + ], + 'bug-2199-diaspora-no-named-size' => [ + 'expectedHtml' => 'Test text', + 'text' => '[size=xx-large]Test text[/size]', + // Triggers the diaspora compatible output + 'simpleHtml' => 3, + ], + 'bug-2199-diaspora-no-numeric-size' => [ + 'expectedHtml' => 'Test text', + 'text' => '[size=24]Test text[/size]', + // Triggers the diaspora compatible output + 'simpleHtml' => 3, + ], ]; }