From d7f0ffdbc17df9633cb008fffd39afb0f7416d20 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 17 May 2020 16:55:54 +0000 Subject: [PATCH 1/2] Issue 8458: Display big emojis Fixes #8458 --- src/Content/Text/BBCode.php | 10 +++++++++- static/defaults.config.php | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 98c155293..508a325ca 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1724,7 +1724,15 @@ class BBCode // Replace non graphical smilies for external posts if (!$nosmile && !$for_plaintext) { - $text = Smilies::replace($text); + $oldtext = $text; + $text = Smilies::replace($text); + if (DI::config()->get('system', 'big_emojis') && ($simple_html != self::DIASPORA) && ($oldtext != $text)) { + $conv = html_entity_decode(str_replace([' ', "\n", "\r"], '', $text)); + // Emojis are always 4 byte Unicode characters + if (strlen($conv) / mb_strlen($conv) == 4) { + $text = '' . $text . ''; + } + } } if (!$for_plaintext) { diff --git a/static/defaults.config.php b/static/defaults.config.php index 4ef006496..a1d50bb84 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -103,6 +103,10 @@ return [ // chose "Remember me" when logging in is considered logged out. 'auth_cookie_lifetime' => 7, + // big_emojis (Boolean) + // Display "Emoji Only" posts in big. + 'big_emojis' => false, + // block_local_dir (Boolean) // Deny public access to the local user directory. 'block_local_dir' => false, From 23046425350d8ef48ecb5d253903e34f9651a0d5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 17 May 2020 17:28:40 +0000 Subject: [PATCH 2/2] Fix test --- tests/src/Content/Text/BBCodeTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index 1a1d06dc7..35dff87d9 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -58,6 +58,9 @@ class BBCodeTest extends MockedTest $this->configMock->shouldReceive('get') ->with('system', 'no_smilies') ->andReturn(false); + $this->configMock->shouldReceive('get') + ->with('system', 'big_emojis') + ->andReturn(false); $l10nMock = \Mockery::mock(L10n::class); $l10nMock->shouldReceive('t')->withAnyArgs()->andReturnUsing(function ($args) { return $args; });