Skip to content

Commit c30b0cb

Browse files
committed
[core:func] correction for PHP < 5.3.2 (htmlspecialchars)
PHP 5.3.2 未満の環境で、Wiki ページが正常に表示されなくなっていた問題の修正。
1 parent 1993610 commit c30b0cb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

xoops_trust_path/modules/xpwiki/class/func/xpwiki_func.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,10 @@ function unhtmlspecialchars ($str, $quote_style = ENT_COMPAT) {
14861486

14871487
// htmlspecialchars compat to PHP <= 5.3
14881488
function htmlspecialchars ($str, $flags = ENT_COMPAT, $encoding = null, $double_encode = true) {
1489+
static $php523 = null;
1490+
if (is_null($php523)) {
1491+
$php523 = version_compare(PHP_VERSION, '5.2.3', '>=');
1492+
}
14891493
if (is_null($encoding)) {
14901494
$encoding = $this->cont['CONTENT_CHARSET'];
14911495
switch ($encoding) {
@@ -1495,7 +1499,15 @@ function htmlspecialchars ($str, $flags = ENT_COMPAT, $encoding = null, $double_
14951499
break;
14961500
}
14971501
}
1498-
return htmlspecialchars($str, $flags, $encoding, $double_encode);
1502+
if ($php523) {
1503+
return htmlspecialchars($str, $flags, $encoding, $double_encode);
1504+
} else {
1505+
$ret = htmlspecialchars($str, $flags, $encoding);
1506+
if (! $double_encode) {
1507+
$ret = str_replace('&amp;amp;', '&amp;', $ret);
1508+
}
1509+
return $ret;
1510+
}
14991511
}
15001512

15011513
// ページ頭文字読みの配列を取得

0 commit comments

Comments
 (0)