Skip to content

Commit

Permalink
Merge branch 'feature/utf8mb4' of github.com:nikosdion/joomla-cms int…
Browse files Browse the repository at this point in the history
…o feature/utf8mb4
  • Loading branch information
Nicholas K. Dionysopoulos committed Jul 10, 2015
2 parents b46edd8 + c4a7a21 commit f65ca44
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 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,33 @@ 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 f65ca44

Please sign in to comment.