From 2cd1a4588b9f3827d80d01ff9433b3837543f787 Mon Sep 17 00:00:00 2001 From: "Nicholas K. Dionysopoulos" Date: Sun, 14 Jun 2015 15:05:53 +0300 Subject: [PATCH] UTF-8 Multibyte (utf8mb4) support JFilterInput should work even when a MySQL connection is not available. --- libraries/joomla/filter/input.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libraries/joomla/filter/input.php b/libraries/joomla/filter/input.php index 09bd10bd2100b..c9fca305e9129 100644 --- a/libraries/joomla/filter/input.php +++ b/libraries/joomla/filter/input.php @@ -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; + } } }