Skip to content

Commit

Permalink
Experimental: force the processed document to be unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDC committed Oct 21, 2017
1 parent d8747d9 commit 2ee0e8f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/CriticalCssProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function process($rawHtml, $name = '', $context = [], $environment = null
{

try {
$document = new DOMDocument();
$document = new \DOMDocument('1.0', 'UTF-8');
$internalErrors = libxml_use_internal_errors(true);
$document->loadHTML(mb_convert_encoding($rawHtml, 'HTML-ENTITIES', 'UTF-8'));
libxml_use_internal_errors($internalErrors);
Expand Down Expand Up @@ -67,7 +67,8 @@ public function process($rawHtml, $name = '', $context = [], $environment = null
try {
$headStyle = new DOMElement('style', $criticalCss);
$document->getElementsByTagName('head')->item(0)->appendChild($headStyle);
return $document->saveHTML();

return html_entity_decode($document->saveHTML(),null,'unicode');
} catch (\Exception $exception) {
error_log($exception->getMessage());
return $rawHtml;
Expand Down

0 comments on commit 2ee0e8f

Please sign in to comment.