Skip to content

Instantly share code, notes, and snippets.

@gplanchat
Created June 5, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gplanchat/3fdc5176b5f6dd26160e to your computer and use it in GitHub Desktop.
Save gplanchat/3fdc5176b5f6dd26160e to your computer and use it in GitHub Desktop.
PHP 5.5 patch for Magento 1.9
<?php
class Mage_Core_Helper_Abstract
{
//...
/**
* Remove html tags, but leave "<" and ">" signs
*
* @param string $html
* @return string
*/
public function removeTags($html)
{
/*
* [gplanchat] Updated code for PHP 5.5+ compatibility
* @see https://wiki.php.net/rfc/remove_preg_replace_eval_modifier
* {{{
*/
$html = preg_replace_callback('# <(?![/a-z]) | (?<=\\s)>(?![a-z]) #xi', function($matches){
return htmlentities($matches[0]);
}, $html);
// }}}
$html = strip_tags($html);
return htmlspecialchars_decode($html);
}
//...
}
@secaliskan
Copy link

How we can use this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment