Merge pull request #7601 from annando/issue-2199

Issue 2199: Diaspora doesn't interpret size elements
This commit is contained in:
Hypolite Petovan 2019-09-05 17:15:01 -04:00 committed by GitHub
commit 2dcb9926bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -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", "<span style=\"font-size: $1px; line-height: initial;\">$2</span>", $text);
$text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism", "<span style=\"font-size: $1; line-height: initial;\">$2</span>", $text);
if ($simple_html != 3) {
$text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism", "<span style=\"font-size: $1px; line-height: initial;\">$2</span>", $text);
$text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism", "<span style=\"font-size: $1; line-height: initial;\">$2</span>", $text);
} else {
// Issue 2199: Diaspora doesn't interpret the construct above, nor the <small> or <big> element
$text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism", "$2", $text);
}
// Check for centered text
$text = preg_replace("(\[center\](.*?)\[\/center\])ism", "<div style=\"text-align:center;\">$1</div>", $text);

View File

@ -176,6 +176,28 @@ class BBCodeTest extends MockedTest
[*]http://example.com/
[/ul]',
],
'bug-2199-named-size' => [
'expectedHtml' => '<span style="font-size: xx-large; line-height: initial;">Test text</span>',
'text' => '[size=xx-large]Test text[/size]',
'simpleHtml' => 0,
],
'bug-2199-numeric-size' => [
'expectedHtml' => '<span style="font-size: 24px; line-height: initial;">Test text</span>',
'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,
],
];
}