diff --git a/lib/auth.php b/lib/auth.php
index 481796a..d6c910a 100644
--- a/lib/auth.php
+++ b/lib/auth.php
@@ -1,7 +1,7 @@
' . $_msg_unfreeze . ')';
@@ -214,7 +214,7 @@ function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
}
if ($exit_flag) {
$body = $title = str_replace('$1',
- htmlspecialchars(strip_bracket($page)), $title_cannot);
+ htmlsc(strip_bracket($page)), $title_cannot);
$page = str_replace('$1', make_search($page), $title_cannot);
catbody($title, $page, $body);
exit;
diff --git a/lib/backup.php b/lib/backup.php
index 2726c09..d46fd8c 100644
--- a/lib/backup.php
+++ b/lib/backup.php
@@ -11,7 +11,7 @@
* @access public
* @author
* @create
- * @version $Id: backup.php,v 1.12 2006/02/02 13:27:57 henoheno Exp $
+ * @version $Id: backup.php,v 1.13 2011/01/25 15:01:01 henoheno Exp $
* Copyright (C)
* 2002-2006 PukiWiki Developers Team
* 2001-2002 Originally written by yu-ji
@@ -67,7 +67,7 @@ function make_backup($page, $delete = FALSE)
$body = preg_replace("/\n*$/", "\n", $body);
$fp = _backup_fopen($page, 'wb')
- or die_message('Cannot open ' . htmlspecialchars(_backup_get_filename($page)) .
+ or die_message('Cannot open ' . htmlsc(_backup_get_filename($page)) .
'
Maybe permission is not writable or filename is too long');
_backup_fputs($fp, $strout);
_backup_fputs($fp, $body);
diff --git a/lib/convert_html.php b/lib/convert_html.php
index f8adc53..eda75bf 100644
--- a/lib/convert_html.php
+++ b/lib/convert_html.php
@@ -1,6 +1,6 @@
style[$name] = $name . ':' . htmlspecialchars($matches[3]) . ';';
+ $this->style[$name] = $name . ':' . htmlsc($matches[3]) . ';';
$text = $matches[5];
} else if ($matches[4]) {
- $this->style['size'] = 'font-size:' . htmlspecialchars($matches[4]) . 'px;';
+ $this->style['size'] = 'font-size:' . htmlsc($matches[4]) . 'px;';
$text = $matches[5];
}
}
@@ -726,7 +726,7 @@ class Pre extends Element
{
global $preformat_ltrim;
parent::Element();
- $this->elements[] = htmlspecialchars(
+ $this->elements[] = htmlsc(
(! $preformat_ltrim || $text == '' || $text{0} != ' ') ? $text : substr($text, 1));
}
diff --git a/lib/diff.php b/lib/diff.php
index 19a9916..c44cefc 100644
--- a/lib/diff.php
+++ b/lib/diff.php
@@ -1,6 +1,6 @@
';
$params = array($_obj->get('left'), $_obj->get('right'), $_obj->text());
foreach ($params as $key=>$text) {
- $text = htmlspecialchars($text);
+ $text = htmlsc($text);
if (trim($text) == '') $text = ' ';
$do_update_diff_table .= '<' . $tags[$key] .
' class="style_' . $tags[$key] . '">' . $text .
diff --git a/lib/file.php b/lib/file.php
index dec5781..ea9cad3 100644
--- a/lib/file.php
+++ b/lib/file.php
@@ -1,6 +1,6 @@
' . "\n" .
'Maybe permission is not writable or filename is too long');
set_file_buffer($fp, 0);
@@ -285,7 +285,7 @@ function add_recent($page, $recentpage, $subject = '', $limit = 0)
// Add
array_unshift($lines, '-' . format_date(UTIME) . ' - ' . $_page .
- htmlspecialchars($subject) . "\n");
+ htmlsc($subject) . "\n");
// Get latest $limit reports
$lines = array_splice($lines, 0, $limit);
@@ -293,7 +293,7 @@ function add_recent($page, $recentpage, $subject = '', $limit = 0)
// Update
$fp = fopen(get_filename($recentpage), 'w') or
die_message('Cannot write page file ' .
- htmlspecialchars($recentpage) .
+ htmlsc($recentpage) .
'
Maybe permission is not writable or filename is too long');
set_file_buffer($fp, 0);
flock($fp, LOCK_EX);
@@ -377,7 +377,7 @@ function lastmodified_add($update = '', $remove = '')
// Open
pkwk_touch_file($file);
$fp = fopen($file, 'r+') or
- die_message('Cannot open ' . htmlspecialchars($whatsnew));
+ die_message('Cannot open ' . htmlsc($whatsnew));
set_file_buffer($fp, 0);
flock($fp, LOCK_EX);
@@ -385,8 +385,8 @@ function lastmodified_add($update = '', $remove = '')
ftruncate($fp, 0);
rewind($fp);
foreach ($recent_pages as $_page=>$time)
- fputs($fp, '-' . htmlspecialchars(format_date($time)) .
- ' - ' . '[[' . htmlspecialchars($_page) . ']]' . "\n");
+ fputs($fp, '-' . htmlsc(format_date($time)) .
+ ' - ' . '[[' . htmlsc($_page) . ']]' . "\n");
fputs($fp, '#norelated' . "\n"); // :)
flock($fp, LOCK_UN);
@@ -441,15 +441,15 @@ function put_lastmodified()
$file = get_filename($whatsnew);
pkwk_touch_file($file);
$fp = fopen($file, 'r+') or
- die_message('Cannot open ' . htmlspecialchars($whatsnew));
+ die_message('Cannot open ' . htmlsc($whatsnew));
set_file_buffer($fp, 0);
flock($fp, LOCK_EX);
ftruncate($fp, 0);
rewind($fp);
foreach (array_keys($recent_pages) as $page) {
$time = $recent_pages[$page];
- $s_lastmod = htmlspecialchars(format_date($time));
- $s_page = htmlspecialchars($page);
+ $s_lastmod = htmlsc(format_date($time));
+ $s_page = htmlsc($page);
fputs($fp, '-' . $s_lastmod . ' - [[' . $s_page . ']]' . "\n");
}
fputs($fp, '#norelated' . "\n"); // :)
@@ -730,12 +730,12 @@ function pkwk_chown($filename, $preserve_time = TRUE)
$lockfile = CACHE_DIR . 'pkwk_chown.lock';
$flock = fopen($lockfile, 'a') or
die('pkwk_chown(): fopen() failed for: CACHEDIR/' .
- basename(htmlspecialchars($lockfile)));
+ basename(htmlsc($lockfile)));
flock($flock, LOCK_EX) or die('pkwk_chown(): flock() failed for lock');
// Check owner
$stat = stat($filename) or
- die('pkwk_chown(): stat() failed for: ' . basename(htmlspecialchars($filename)));
+ die('pkwk_chown(): stat() failed for: ' . basename(htmlsc($filename)));
if ($stat[4] === $php_uid) {
// NOTE: Windows always here
$result = TRUE; // Seems the same UID. Nothing to do
@@ -746,7 +746,7 @@ function pkwk_chown($filename, $preserve_time = TRUE)
// NOTE: Not 'r+'. Don't check write permission here
$ffile = fopen($filename, 'r') or
die('pkwk_chown(): fopen() failed for: ' .
- basename(htmlspecialchars($filename)));
+ basename(htmlsc($filename)));
// Try to chown by re-creating files
// NOTE:
@@ -786,7 +786,7 @@ function pkwk_touch_file($filename, $time = FALSE, $atime = FALSE)
return $result;
} else {
die('pkwk_touch_file(): Invalid UID and (not writable for the directory or not a flie): ' .
- htmlspecialchars(basename($filename)));
+ htmlsc(basename($filename)));
}
}
?>
diff --git a/lib/func.php b/lib/func.php
index d760dfe..43db3dd 100644
--- a/lib/func.php
+++ b/lib/func.php
@@ -1,6 +1,6 @@
' . "\n";
foreach (array_keys($pages) as $page) {
$r_page = rawurlencode($page);
- $s_page = htmlspecialchars($page);
+ $s_page = htmlsc($page);
$passage = $show_passage ? ' ' . get_passage(get_filetime($page)) : '';
$retval .= '
Sorry, page \'' . htmlspecialchars($rule_page) . + return '
Sorry, page \'' . htmlsc($rule_page) . '\' unavailable.
'; } else { return convert_html(get_source($rule_page)); @@ -631,7 +631,7 @@ function get_script_uri($init_uri = '') if (isset($script_directory_index)) { if (! file_exists($script_directory_index)) die_message('Directory index file not found: ' . - htmlspecialchars($script_directory_index)); + htmlsc($script_directory_index)); $matches = array(); if (preg_match('#^(.+/)' . preg_quote($script_directory_index, '#') . '$#', $script, $matches)) $script = $matches[1]; @@ -701,6 +701,13 @@ function csv_implode($glue, $pieces) return join($glue, $arr); } +// Sugar with default settings +function htmlsc($string = '', $flags = ENT_QUOTES, $charset = CONTENT_CHARSET) +{ + return htmlspecialchars($string, $flags, $charset); // htmlsc() +} + + //// Compat //// // is_a -- Returns TRUE if the object is of this class or has this class as one of its parents diff --git a/lib/html.php b/lib/html.php index c5047d7..965ae07 100644 --- a/lib/html.php +++ b/lib/html.php @@ -1,6 +1,6 @@ ' . $_msg_word . htmlspecialchars($vars['word']) . + $body = '