Skip to content

Commit

Permalink
Replace xss_entity_decode_callback() method with lambda function
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Mar 9, 2017
1 parent b59ff5c commit 05aae47
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions program/lib/Roundcube/rcube_utils.php
Expand Up @@ -493,27 +493,16 @@ public static function file2class($mimetype, $filename)
*/
public static function xss_entity_decode($content)
{
$callback = function($matches) { return chr(hexdec($matches[1])); };

$out = html_entity_decode(html_entity_decode($content));
$out = strip_tags($out);
$out = preg_replace_callback('/\\\([0-9a-f]{4})/i',
array(self, 'xss_entity_decode_callback'), $out);
$out = preg_replace_callback('/\\\([0-9a-f]{4})/i', $callback, $out);
$out = preg_replace('#/\*.*\*/#Ums', '', $out);

return $out;
}

/**
* preg_replace_callback callback for xss_entity_decode
*
* @param array $matches Result from preg_replace_callback
*
* @return string Decoded entity
*/
public static function xss_entity_decode_callback($matches)
{
return chr(hexdec($matches[1]));
}

/**
* Check if we can process not exceeding memory_limit
*
Expand Down

0 comments on commit 05aae47

Please sign in to comment.