specialchar charset fallback on early calls (#236, #240)

This commit is contained in:
onli 2014-12-07 17:44:26 +01:00
parent 0204a597c7
commit d91b86486b

View File

@ -422,6 +422,13 @@ function serendipity_specialchars($string, $flags = null, $encoding = LANG_CHARS
$flags = ENT_COMPAT;
}
}
if ($encoding == 'LANG_CHARSET') {
// if called before LANG_CHARSET is set, we need to set a fallback encoding to not throw a php warning that
// would kill s9y blogs sometimes (https://github.com/s9y/Serendipity/issues/236)
$encoding = 'UTF-8';
}
return htmlspecialchars($string, $flags, $encoding, $double_encode);
}
@ -438,6 +445,9 @@ function serendipity_entities($string, $flags = null, $encoding = LANG_CHARSET,
$flags = ENT_COMPAT;
}
}
if ($encoding == 'LANG_CHARSET') {
$encoding = 'UTF-8';
}
return htmlentities($string, $flags, $encoding, $double_encode);
}
@ -456,6 +466,9 @@ function serendipity_entity_decode($string, $flags = null, $encoding = LANG_CHAR
$flags = ENT_COMPAT;
}
}
if ($encoding == 'LANG_CHARSET') {
$encoding = 'UTF-8';
}
return html_entity_decode($string, $flags, $encoding, $double_encode);
}