• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoapythonrubywindowsphpgameguibathyscaphec翻訳omegatframework計画中(planning stage)twitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

PukiWiki


Commit MetaInfo

Revisione72eb8997265134c2ecc95173e2570d99e7cbcee (tree)
Time2014-06-02 06:01:07
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

Replace 'htmlspecialchars' by 'htmlsc'

The behavior of 'htmlspecialchars' has changed in PHP 5.4.
The default value of 3rd parameter $encoding is UTF-8.
Almost all EUC_JP characters are handled as invalid UTF-8
sequence and that cause empty output.
http://docs.php.net/manual/en/function.htmlspecialchars.php

The solution used in 'htmlsc' is setting $encoding explicitly.

Change Summary

Incremental Difference

--- a/lib/func.php
+++ b/lib/func.php
@@ -356,14 +356,14 @@ function page_list($pages, $cmd = 'read', $withfilename = FALSE)
356356
357357 foreach($pages as $file=>$page) {
358358 $r_page = rawurlencode($page);
359- $s_page = htmlspecialchars($page, ENT_QUOTES);
359+ $s_page = htmlsc($page, ENT_QUOTES);
360360 $passage = get_pg_passage($page);
361361
362362 $str = ' <li><a href="' . $href . $r_page . '">' .
363363 $s_page . '</a>' . $passage;
364364
365365 if ($withfilename) {
366- $s_file = htmlspecialchars($file);
366+ $s_file = htmlsc($file);
367367 $str .= "\n" . ' <ul><li>' . $s_file . '</li></ul>' .
368368 "\n" . ' ';
369369 }
--- a/plugin/ls2.inc.php
+++ b/plugin/ls2.inc.php
@@ -106,7 +106,7 @@ function plugin_ls2_show_lists($prefix, & $params)
106106 foreach ($pages as $page) $params["page_$page"] = 0;
107107
108108 if (empty($pages)) {
109- return str_replace('$1', htmlspecialchars($prefix), $_ls2_err_nopages);
109+ return str_replace('$1', htmlsc($prefix), $_ls2_err_nopages);
110110 } else {
111111 $params['result'] = $params['saved'] = array();
112112 foreach ($pages as $page)
--- a/plugin/referer.inc.php
+++ b/plugin/referer.inc.php
@@ -99,8 +99,8 @@ function plugin_referer_body($page, $sort)
9999 list($ltime, $stime, $count, $url, $enable) = $arr;
100100
101101 // 非ASCIIキャラクタ(だけ)をURLエンコードしておく BugTrack/440
102- $e_url = htmlspecialchars(preg_replace('/([" \x80-\xff]+)/e', 'rawurlencode("$1")', $url));
103- $s_url = htmlspecialchars(mb_convert_encoding(rawurldecode($url), SOURCE_ENCODING, 'auto'));
102+ $e_url = htmlsc(preg_replace('/([" \x80-\xff]+)/e', 'rawurlencode("$1")', $url));
103+ $s_url = htmlsc(mb_convert_encoding(rawurldecode($url), SOURCE_ENCODING, 'auto'));
104104
105105 $lpass = get_passage($ltime, FALSE); // 最終更新日時からの経過時間
106106 $spass = get_passage($stime, FALSE); // 初回登録日時からの経過時間
@@ -164,7 +164,7 @@ function plugin_referer_set_color()
164164 // BGCOLOR(#88ff88)
165165 $matches = array();
166166 foreach ($pconfig_color as $x)
167- $color[$x[0]] = htmlspecialchars(
167+ $color[$x[0]] = htmlsc(
168168 preg_match('/BGCOLOR\(([^)]+)\)/si', $x[1], $matches) ?
169169 $matches[1] : $x[1]);
170170 }
--- a/plugin/tracker.inc.php
+++ b/plugin/tracker.inc.php
@@ -91,7 +91,7 @@ function plugin_tracker_action()
9191 $config = new Config('plugin/tracker/'.$config_name);
9292 if (!$config->read())
9393 {
94- return "<p>config file '".htmlspecialchars($config_name)."' not found.</p>";
94+ return "<p>config file '".htmlsc($config_name)."' not found.</p>";
9595 }
9696 $config->config_name = $config_name;
9797 $source = $config->page.'/page';
@@ -199,7 +199,7 @@ function plugin_tracker_inline()
199199
200200 if (!$config->read())
201201 {
202- return "config file '".htmlspecialchars($config_name)."' not found.";
202+ return "config file '".htmlsc($config_name)."' not found.";
203203 }
204204
205205 $config->config_name = $config_name;
@@ -439,7 +439,7 @@ class Tracker_field_radio extends Tracker_field_format
439439
440440 function get_tag()
441441 {
442- $s_name = htmlspecialchars($this->name);
442+ $s_name = htmlsc($this->name);
443443 $retval = '';
444444 $id = 0;
445445 foreach ($this->config->get($this->name) as $option)
--- a/plugin/versionlist.inc.php
+++ b/plugin/versionlist.inc.php
@@ -44,12 +44,12 @@ function plugin_versionlist_convert()
4444 continue;
4545 }
4646 $data = join('',file($sdir.$file));
47- $comment = array('file'=>htmlspecialchars($sdir.$file),'rev'=>'','date'=>'');
47+ $comment = array('file'=>htmlsc($sdir.$file),'rev'=>'','date'=>'');
4848 if (preg_match('/\$'.'Id: (.+),v (\d+\.\d+) (\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2})/',$data,$matches))
4949 {
50-// $comment['file'] = htmlspecialchars($sdir.$matches[1]);
51- $comment['rev'] = htmlspecialchars($matches[2]);
52- $comment['date'] = htmlspecialchars($matches[3]);
50+// $comment['file'] = htmlsc($sdir.$matches[1]);
51+ $comment['rev'] = htmlsc($matches[2]);
52+ $comment['date'] = htmlsc($matches[3]);
5353 }
5454 $comments[$sdir.$file] = $comment;
5555 }