aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3D-I <480857+3D-I@users.noreply.github.com>2019-09-10 05:59:08 +0200
committer3D-I <480857+3D-I@users.noreply.github.com>2019-09-10 06:00:59 +0200
commit78c1957e48d58672690d67b4450ab32687242944 (patch)
tree529d5937ade7acfb6d1bd377ad2d801018e7ebd5 /phpBB/posting.php
parentMerge pull request #5666 from mrgoldy/ticket/16084 (diff)
downloadphpbb-78c1957e48d58672690d67b4450ab32687242944.tar.gz
phpbb-78c1957e48d58672690d67b4450ab32687242944.tar.bz2
phpbb-78c1957e48d58672690d67b4450ab32687242944.zip
[ticket/16153] Enable Emojis and rich text in Topic title
PHPBB3-16153
Diffstat (limited to 'phpBB/posting.php')
-rw-r--r--phpBB/posting.php28
1 files changed, 25 insertions, 3 deletions
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('<br />', $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('<br>', $matches[0]);
+
$error[] = $user->lang('UNSUPPORTED_CHARACTERS_SUBJECT', $character_list);
}