Fix htmlspecialchars(): Invalid multibyte sequence in argument Error

Problem

You may see below error in ISC System Log after implementing the Use Product Description as Open Graph Description in ISC hack or Use Product Description as Meta Description in ISC hack

htmlspecialchars() [function.htmlspecialchars]: Invalid multibyte sequence in argument

It is due to product description content charset encoding issue with multibyte characters.

Solution

In /includes/classes/class.opengraph.php

Find

$metaTagsHTML .= '<meta property="' . $propertyName . '" content="' . isc_html_escape($tagContent) . '" />' . "\n";

Replace

$metaTagsHTML .= '<meta property="' . $propertyName . '" content="' . htmlspecialchars($tagContent,ENT_IGNORE,'UTF-8') . '" />' . "\n";

In /includes/classes/class.product.php

Find

$GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription(isc_html_escape($this->_prodmetadesc));

Replace

$GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription(htmlspecialchars($this->_prodmetadesc,ENT_IGNORE,'UTF-8'));

Note: ENT_IGNORESilently discard invalid code unit sequences instead of returning an empty string.

Leave a Reply

Your email address will not be published. Required fields are marked *