Skip to content

Commit

Permalink
Check for ENT_HTML401 existance to make the patch work with PHP 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
garvinhicking committed Nov 24, 2014
1 parent eab43b1 commit 73f417f
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions include/compat.inc.php
Expand Up @@ -414,7 +414,13 @@ function serendipity_die($html) {
*/
function serendipity_specialchars($string, $flags = null, $encoding = LANG_CHARSET, $double_encode = true) {
if ($flags == null) {
$flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
if (defined('ENT_HTML401')) {
// Added with PHP 5.4.x
$flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
} else {
// For PHP < 5.4 compatibility
$flags = ENT_COMPAT;
}
}
return htmlspecialchars($string, $flags, $encoding, $double_encode);
}
Expand All @@ -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) {
if ($flags == null) {
$flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
if (defined('ENT_HTML401')) {
// Added with PHP 5.4.x
$flags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
} else {
// For PHP < 5.4 compatibility
$flags = ENT_COMPAT;
}
}
return htmlentities($string, $flags, $encoding, $double_encode);
}
Expand All @@ -436,7 +448,13 @@ function serendipity_entity_decode($string, $flags = null, $encoding = LANG_CHAR
if ($flags == null) {
# 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
$flags = ENT_COMPAT | ENT_HTML401;
if (defined('ENT_HTML401')) {
// Added with PHP 5.4.x
$flags = ENT_COMPAT | ENT_HTML401;
} else {
// For PHP < 5.4 compatibility
$flags = ENT_COMPAT;
}
}
return html_entity_decode($string, $flags, $encoding, $double_encode);
}
Expand Down

0 comments on commit 73f417f

Please sign in to comment.