Skip to content

Commit

Permalink
UTF-8 Multibyte (utf8mb4) support
Browse files Browse the repository at this point in the history
Fixed a problem with JFilterInput and arrays.
  • Loading branch information
Nicholas K. Dionysopoulos committed Jun 16, 2015
1 parent 3e44ac8 commit 2f17b52
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion libraries/joomla/filter/input.php
Expand Up @@ -231,7 +231,7 @@ public function clean($source, $type = 'string')
if ($this->stripUSC)
{
// 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);
$source = $this->stripUSC($source);
}

// Handle the type constraint
Expand Down Expand Up @@ -1128,4 +1128,34 @@ protected function _stripCSSExpressions($source)

return $return;
}

/**
*
* Recursively strip Unicode Supplementary Characters from the source. Not: objects cannot be filtered.
*
* @param mixed $source The data to filter
*
* @return mixed The filtered result
*/
protected function stripUSC($source)
{
if (is_object($source))
{
return $source;
}

if (is_array($source))
{
$filteredArray = array();

foreach ($source as $k => $v)
{
$filteredArray[$k] = $this->stripUSC($v);
}

return $filteredArray;
}

return preg_replace('/[\xF0-\xF7].../s', "\xE2\xAF\x91", $source);
}
}

0 comments on commit 2f17b52

Please sign in to comment.