1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Use UTF-8 encoding for htmlspecialchars. See #36.

Prior to PHP 5.4.0 the default encoding for `htmlentities()`
and `htmlspecialchars` is "ISO-8859-1". For PHP 5.4+ is "UTF-8".

This ensures always the right encoding is used no matter the PHP version
and the locale settings.
This commit is contained in:
Haralan Dobrev
2013-11-22 23:06:20 +02:00
parent 28064a63b3
commit 849a89b121
3 changed files with 5 additions and 2 deletions

View File

@@ -568,7 +568,7 @@ class Parsedown
case 'code_block':
case 'fenced_code_block':
$text = htmlspecialchars($element['text'], ENT_NOQUOTES);
$text = htmlspecialchars($element['text'], ENT_NOQUOTES, 'UTF-8');
strpos($text, "\x1A\\") !== FALSE and $text = strtr($text, $this->escape_sequence_map);
@@ -634,7 +634,7 @@ class Parsedown
foreach ($matches as $matches)
{
$element_text = $matches[1];
$element_text = htmlspecialchars($element_text, ENT_NOQUOTES);
$element_text = htmlspecialchars($element_text, ENT_NOQUOTES, 'UTF-8');
# decodes escape sequences