Skip to content

Commit

Permalink
Document output UTF-8 encoding fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksydan committed Mar 5, 2023
1 parent a2f31ad commit 19deb07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Core/Smarty/SmartyHelperFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static function displayDesktopBlock($params, $content, $smarty)
public static function cmsImagesBlock($params, $content, $smarty)
{
$doc = new \DOMDocument();
$doc->loadHTML('<?xml encoding="utf-8" ?>' . $content);
$doc->loadHTML('<meta http-equiv="Content-Type" content="charset=utf-8">' . $content);
$context = \Context::getContext();

$images = $doc->getElementsByTagName('img');
Expand Down Expand Up @@ -173,7 +173,7 @@ public static function cmsImagesBlock($params, $content, $smarty)
}

$content = $doc->saveHTML();
$content = str_replace('<?xml encoding="utf-8" ?>', '', $content);
$content = str_replace('<meta http-equiv="Content-Type" content="charset=utf-8">', '', $content);

$webpEnabled = isset($params['webpEnabled']) ? $params['webpEnabled'] : \Configuration::get(WebpConfiguration::THEMECORE_WEBP_ENABLED);

Expand Down
4 changes: 2 additions & 2 deletions src/Hook/HtmlOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function hookActionOutputHTMLBefore(array $params): void
$preConfig = libxml_use_internal_errors(true);
$html = $params['html'];
$doc = new \DOMDocument();
$doc->loadHTML('<?xml encoding="utf-8" ?>' . $html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$doc->loadHTML('<meta http-equiv="Content-Type" content="charset=utf-8">' . $html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$links = $doc->getElementsByTagName('link');

foreach ($links as $link) {
Expand Down Expand Up @@ -77,7 +77,7 @@ public function hookActionOutputHTMLBefore(array $params): void

if ($webpEnabled) {
$content = $doc->saveHTML();
$content = str_replace('<?xml encoding="utf-8" ?>', '', $content);
$content = str_replace('<meta http-equiv="Content-Type" content="charset=utf-8">', '', $content);
$params['html'] = $content;
}

Expand Down

0 comments on commit 19deb07

Please sign in to comment.