Skip to content

Commit

Permalink
UTF-8 Multibyte (utf8mb4) support
Browse files Browse the repository at this point in the history
JFilterInput should work even when a MySQL connection is not available.
  • Loading branch information
Nicholas K. Dionysopoulos committed Jun 14, 2015
1 parent b7154fb commit 2cd1a45
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions libraries/joomla/filter/input.php
Expand Up @@ -152,12 +152,20 @@ public function __construct($tagsArray = array(), $attrArray = array(), $tagsMet
*/
if ($this->stripUSC == -1)
{
// 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;
try
{
// 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;
}
catch (Exception $e)
{
// Could not connect to MySQL. Strip USC to be on the safe side.
$this->stripUSC = 1;
}
}
}

Expand Down

0 comments on commit 2cd1a45

Please sign in to comment.