Fixed encoding problems when PHP INI setting default_charset is not utf-8 (Grav 1.7 edition) [#2154]

This commit is contained in:
Matias Griese
2020-02-10 10:19:11 +02:00
parent 3f56c5a727
commit 3a722ba44e
3 changed files with 7 additions and 7 deletions

View File

@@ -400,7 +400,7 @@ class Pages
$param = $uri->param(rawurlencode($taxonomy));
$items = is_string($param) ? explode(',', $param) : [];
foreach ($items as $item) {
$params['taxonomies'][$taxonomy][] = htmlspecialchars_decode(rawurldecode($item), ENT_QUOTES);
$params['taxonomies'][$taxonomy][] = htmlspecialchars_decode(rawurldecode($item), ENT_QUOTES | ENT_HTML5);
}
}
}

View File

@@ -635,12 +635,12 @@ trait PageContentTrait
// Only return string but not html, wrap whatever html tag you want when using.
if ($textOnly) {
return mb_strimwidth($content, 0, $size, '...', 'utf-8');
return mb_strimwidth($content, 0, $size, '...', 'UTF-8');
}
$summary = Utils::truncateHTML($content, $size);
return html_entity_decode($summary);
return html_entity_decode($summary, ENT_COMPAT | ENT_HTML5, 'UTF-8');
}
/**

View File

@@ -627,7 +627,7 @@ trait PageLegacyTrait
$this->_metadata[$prop_key] = [
'name' => $prop_key,
'property' => $prop_key,
'content' => htmlspecialchars($prop_value, ENT_QUOTES, 'UTF-8')
'content' => htmlspecialchars($prop_value, ENT_QUOTES | ENT_HTML5, 'UTF-8')
];
}
} elseif ($value) {
@@ -635,16 +635,16 @@ trait PageLegacyTrait
if (\in_array($key, $header_tag_http_equivs, true)) {
$this->_metadata[$key] = [
'http_equiv' => $key,
'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
'content' => htmlspecialchars($value, ENT_QUOTES | ENT_HTML5, 'UTF-8')
];
} elseif ($key === 'charset') {
$this->_metadata[$key] = ['charset' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')];
$this->_metadata[$key] = ['charset' => htmlspecialchars($value, ENT_QUOTES | ENT_HTML5, 'UTF-8')];
} else {
// if it's a social metadata with separator, render as property
$separator = strpos($key, ':');
$hasSeparator = $separator && $separator < strlen($key) - 1;
$entry = [
'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
'content' => htmlspecialchars($value, ENT_QUOTES | ENT_HTML5, 'UTF-8')
];
if ($hasSeparator && !Utils::startsWith($key, 'twitter')) {