Skip to content

Instantly share code, notes, and snippets.

@marc1706
Created July 19, 2013 15:29
Show Gist options
  • Save marc1706/6040025 to your computer and use it in GitHub Desktop.
Save marc1706/6040025 to your computer and use it in GitHub Desktop.
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index a134fab..09f02b1 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -1173,6 +1173,20 @@ class parse_message extends bbcode_firstpass
}
}
+ // Check for out-of-bounds characters that are currently
+ // not supported by utf8_bin
+ if (preg_match('/[\x{10000}-\x{10FFFF}]/u', $this->message, $matches))
+ {
+ $character_list = '';
+ foreach ($matches as $cur_match)
+ {
+ $character_list .= $cur_match . '<br />';
+ }
+ $this->warn_msg[] = $user->lang['UNSUPPORTED_CHARACTERS'] . $character_list;
+ return $this->warn_msg;
+ }
+
+
// Check for "empty" message. We do not check here for maximum length, because bbcode, smilies, etc. can add to the length.
// The maximum length check happened before any parsings.
if ($mode === 'post' && utf8_clean_string($this->message) === '')
diff --git a/phpBB/language/en/posting.php b/phpBB/language/en/posting.php
index dfc5065..61e064d 100644
--- a/phpBB/language/en/posting.php
+++ b/phpBB/language/en/posting.php
@@ -205,6 +205,7 @@ $lang = array_merge($lang, array(
'UNAUTHORISED_BBCODE' => 'You cannot use certain BBCodes: %s.',
'UNGLOBALISE_EXPLAIN' => 'To switch this topic back from being global to a normal topic, you need to select the forum you wish this topic to be displayed.',
+ 'UNSUPPORTED_CHARACTERS' => 'Your message contains the following unsupported characters:<br />',
'UPDATE_COMMENT' => 'Update comment',
'URL_INVALID' => 'The URL you specified is invalid.',
'URL_NOT_FOUND' => 'The file specified could not be found.',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment