From 78c1957e48d58672690d67b4450ab32687242944 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 10 Sep 2019 05:59:08 +0200 Subject: [ticket/16153] Enable Emojis and rich text in Topic title PHPBB3-16153 --- phpBB/includes/functions_display.php | 3 ++- phpBB/posting.php | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 792467019f..3a2f4a7249 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -539,7 +539,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod { if ($row['forum_password_last_post'] === '' && $auth->acl_gets('f_read', 'f_list_topics', $row['forum_id_last_post'])) { - $last_post_subject = censor_text($row['forum_last_post_subject']); + $last_post_subject = utf8_decode_ncr(censor_text($row['forum_last_post_subject'])); + $last_post_subject_truncated = truncate_string($last_post_subject, 30, 255, false, $user->lang['ELLIPSIS']); } else diff --git a/phpBB/posting.php b/phpBB/posting.php index 5089448483..11237bf050 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1178,11 +1178,33 @@ if ($submit || $preview || $refresh) $error[] = $user->lang['EMPTY_SUBJECT']; } - // Check for out-of-bounds characters that are currently - // not supported by utf8_bin in MySQL + /** + * Replace Emojis and other 4bit UTF-8 chars, not allowed by utf8_bin MySql, to NCR. + * Using their Numeric Character Reference's Hexadecimal notation. + * Doesn't interfere with Japanese or Cyrillic etc. + * + * @see https://www.w3.org/TR/xml11/ + * @see https://www.opentag.com/xfaq_charrep.htm + */ if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $post_data['post_subject'], $matches)) { - $character_list = implode('
', $matches[0]); + foreach ($matches as $key => $emoji) + { + $post_data['post_subject'] = str_replace($emoji, utf8_encode_ncr($emoji), $post_data['post_subject']); + } + } + + /** + * This should never happen again. + * Leaving the fallback here just in case there will be the need of it. + * + * Check for out-of-bounds characters that are currently + * not supported by utf8_bin in MySQL + */ + if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $post_data['post_subject'], $matches)) + { + $character_list = implode('
', $matches[0]); + $error[] = $user->lang('UNSUPPORTED_CHARACTERS_SUBJECT', $character_list); } -- cgit v1.2.1 From bcac30c8bbc1839fd20ef612faccaffc5df74464 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Wed, 11 Sep 2019 01:46:02 +0200 Subject: [ticket/16153] Functional test PHPBB3-16153 --- tests/functional/posting_test.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 764376a945..298bb40a90 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -46,9 +46,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case self::create_post(2, 1, "Unsupported: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", - 'This is a test with emoji characters in the topic title.', - array(), - 'Your subject contains the following unsupported characters' + 'This is a test with emoji characters in the topic title.' ); } -- cgit v1.2.1 From 41728f2258c409480b9c3d4c1753b6eb1b47c677 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Wed, 11 Sep 2019 03:44:12 +0200 Subject: [ticket/16153] Functional test 2 PHPBB3-16153 --- tests/functional/posting_test.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 298bb40a90..e4b23c3215 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -41,13 +41,10 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case { $this->login(); - $this->add_lang('posting'); - - self::create_post(2, - 1, - "Unsupported: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", - 'This is a test with emoji characters in the topic title.' - ); + $post = $this->create_topic(2, "Test Topic \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji character in the topic title.'); + $this->create_post(2, $post['topic_id'], "Re: Test Topic 1 \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji characters in the topic title.'); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + $this->assertContains("\xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", $crawler->text()); } public function test_supported_unicode_characters() -- cgit v1.2.1 From c569d0dabc0868356c2c2f6bdf796c6433756fa2 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Mon, 28 Oct 2019 21:14:57 +0100 Subject: [ticket/16153] Use new function PHPBB3-16153 --- phpBB/posting.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index 5bba052a6a..9f3b26aa85 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1182,20 +1182,10 @@ if ($submit || $preview || $refresh) } /** - * Replace Emojis and other 4bit UTF-8 chars, not allowed by utf8_bin MySql, to NCR. + * Replace Emojis and other 4bit UTF-8 chars not allowed by MySql to UCR / NCR. * Using their Numeric Character Reference's Hexadecimal notation. - * Doesn't interfere with Japanese or Cyrillic etc. - * - * @see https://www.w3.org/TR/xml11/ - * @see https://www.opentag.com/xfaq_charrep.htm */ - if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $post_data['post_subject'], $matches)) - { - foreach ($matches as $key => $emoji) - { - $post_data['post_subject'] = str_replace($emoji, utf8_encode_ncr($emoji), $post_data['post_subject']); - } - } + $post_data['post_subject'] = utf8_encode_ucr($post_data['post_subject']); /** * This should never happen again. -- cgit v1.2.1 From ff25d0a5084e5e79bf7cc9faefd0dfdeb0ef5705 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Wed, 30 Oct 2019 14:47:05 +0100 Subject: [ticket/16153] Enable Emojis and rich text in Topic title PHPBB3-16153 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index 9f3b26aa85..a0ddb9ff15 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1182,7 +1182,7 @@ if ($submit || $preview || $refresh) } /** - * Replace Emojis and other 4bit UTF-8 chars not allowed by MySql to UCR / NCR. + * Replace Emojis and other 4bit UTF-8 chars not allowed by MySQL to UCR/NCR. * Using their Numeric Character Reference's Hexadecimal notation. */ $post_data['post_subject'] = utf8_encode_ucr($post_data['post_subject']); -- cgit v1.2.1