Check for ENT_HTML401 existance to make the patch work with PHP 5.3
This commit is contained in:
@ -414,7 +414,13 @@ if (function_exists('date_default_timezone_get')) {
|
|||||||
*/
|
*/
|
||||||
function serendipity_specialchars($string, $flags = null, $encoding = LANG_CHARSET, $double_encode = true) {
|
function serendipity_specialchars($string, $flags = null, $encoding = LANG_CHARSET, $double_encode = true) {
|
||||||
if ($flags == null) {
|
if ($flags == null) {
|
||||||
|
if (defined('ENT_HTML401')) {
|
||||||
|
// Added with PHP 5.4.x
|
||||||
$flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
|
$flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
|
||||||
|
} else {
|
||||||
|
// For PHP < 5.4 compatibility
|
||||||
|
$flags = ENT_COMPAT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return htmlspecialchars($string, $flags, $encoding, $double_encode);
|
return htmlspecialchars($string, $flags, $encoding, $double_encode);
|
||||||
}
|
}
|
||||||
@ -424,7 +430,13 @@ function serendipity_specialchars($string, $flags = null, $encoding = LANG_CHARS
|
|||||||
*/
|
*/
|
||||||
function serendipity_entities($string, $flags = null, $encoding = LANG_CHARSET, $double_encode = true) {
|
function serendipity_entities($string, $flags = null, $encoding = LANG_CHARSET, $double_encode = true) {
|
||||||
if ($flags == null) {
|
if ($flags == null) {
|
||||||
|
if (defined('ENT_HTML401')) {
|
||||||
|
// Added with PHP 5.4.x
|
||||||
$flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
|
$flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
|
||||||
|
} else {
|
||||||
|
// For PHP < 5.4 compatibility
|
||||||
|
$flags = ENT_COMPAT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return htmlentities($string, $flags, $encoding, $double_encode);
|
return htmlentities($string, $flags, $encoding, $double_encode);
|
||||||
}
|
}
|
||||||
@ -436,7 +448,13 @@ function serendipity_entity_decode($string, $flags = null, $encoding = LANG_CHAR
|
|||||||
if ($flags == null) {
|
if ($flags == null) {
|
||||||
# NOTE: ENT_SUBSTITUTE does not exist for this function, and the documentation does not specify that it will
|
# NOTE: ENT_SUBSTITUTE does not exist for this function, and the documentation does not specify that it will
|
||||||
# ever echo empty strings on charset errors
|
# ever echo empty strings on charset errors
|
||||||
|
if (defined('ENT_HTML401')) {
|
||||||
|
// Added with PHP 5.4.x
|
||||||
$flags = ENT_COMPAT | ENT_HTML401;
|
$flags = ENT_COMPAT | ENT_HTML401;
|
||||||
|
} else {
|
||||||
|
// For PHP < 5.4 compatibility
|
||||||
|
$flags = ENT_COMPAT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return html_entity_decode($string, $flags, $encoding, $double_encode);
|
return html_entity_decode($string, $flags, $encoding, $double_encode);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user