diff --git a/libraries/joomla/filter/input.php b/libraries/joomla/filter/input.php index c9fca305e9129..02bb2f5e79c68 100644 --- a/libraries/joomla/filter/input.php +++ b/libraries/joomla/filter/input.php @@ -156,8 +156,10 @@ public function __construct($tagsArray = array(), $attrArray = array(), $tagsMet { // Get the database driver $db = JFactory::getDbo(); + // This trick is required to let the driver determine the utf-8 multibyte support $db->connect(); + // And now we can decide if we should strip USCs $this->stripUSC = $db->hasUTF8mb4Support() ? 0 : 1; } @@ -228,8 +230,8 @@ public function clean($source, $type = 'string') // Strip Unicode Supplementary Characters when requested to do so if ($this->stripUSC) { - $source = preg_replace('/[\xF0-\xF7].../s', "\xE2\xAF\x91", $source); // Alternatively: preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xE2\xAF\x91", $source) but it'd be slower. + $source = preg_replace('/[\xF0-\xF7].../s', "\xE2\xAF\x91", $source); } // Handle the type constraint