Skip to content

Instantly share code, notes, and snippets.

@damienwebdev
Created December 14, 2017 19:14
Show Gist options
  • Save damienwebdev/3b42b01988397589bf8501d9582e27cf to your computer and use it in GitHub Desktop.
Save damienwebdev/3b42b01988397589bf8501d9582e27cf to your computer and use it in GitHub Desktop.
Magento Widget XML/HTML Entities 500 Error Fix
<?php
class Mage_Widget_Helper_Data extends Mage_Core_Helper_Abstract
{
/**
* Further refine escaped HTML.
*/
public function escapeHtml($data, $allowedTags = null)
{
$parent = parent::escapeHtml($data, $allowedTags);
if (is_array($parent)) {
$result = array();
foreach ($parent as $item) {
$result[] = $this->escapeHtml($item);
}
} else {
// process single item
if (strlen($parent)) {
$result = preg_replace('/\&(?!(?:amp|lt|gt|#039|quot);)[^ ;]+;/', "<![CDATA[\\0]]>", $parent);
} else {
$result = $parent;
}
}
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment