• R/O
  • HTTP
  • SSH
  • HTTPS

pukiwiki_sandbox: 提交


Commit MetaInfo

修訂9b03a9b54499eef80458f77ea3465599624a97fe (tree)
時間2011-01-24 23:46:45
作者henoheno <henoheno>
Commiterhenoheno

Log Message

htmlsc(): Just sugar for htmlspecialchars(), and a foundation

Change Summary

差異

--- a/spam/checker.php
+++ b/spam/checker.php
@@ -1,5 +1,5 @@
11 <?php
2-// $Id: checker.php,v 1.7 2009/01/04 05:01:34 henoheno Exp $
2+// $Id: checker.php,v 1.8 2011/01/24 14:46:45 henoheno Exp $
33 // Concept-work of spam-uri metrics
44 // Copyright (C) 2006-2007 PukiWiki Developers Team
55 // License: GPL v2 or (at your option) any later version
@@ -9,7 +9,7 @@ error_reporting(E_ALL); // Debug purpose
99 require('spam.php');
1010
1111 // Recursive array_map()
12-// e.g. Sanitilze ALL values (Debug purpose): var_dump(recursive_map('htmlspecialchars', $array));
12+// e.g. Sanitilze ALL values (Debug purpose): var_dump(recursive_map('htmlsc', $array));
1313 function recursive_map($func, $array)
1414 {
1515 if (is_array($array)) {
@@ -25,7 +25,7 @@ function recursive_map($func, $array)
2525
2626 function show_form($string, $asap = FALSE, $progress = TRUE, $pickup = TRUE)
2727 {
28- $string = htmlspecialchars($string);
28+ $string = htmlsc($string);
2929 $asap = $asap ? ' checked' : '';
3030 $progress = $progress ? ' checked' : '';
3131 $pickup = $pickup ? ' checked' : '';
@@ -135,20 +135,20 @@ if (! empty($progress)) {
135135 $tmp = summarize_detail_badhost($progress);
136136 if ($tmp != '') {
137137 echo 'DETAIL_BADHOST: ' .
138- str_replace(' ', '&nbsp; ', nl2br(htmlspecialchars($tmp). "\n"));
138+ str_replace(' ', '&nbsp; ', nl2br(htmlsc($tmp). "\n"));
139139 }
140140 }
141141
142142 $tmp = summarize_detail_newtral($progress);
143143 if (! $asap && $tmp != '') {
144144 echo 'DETAIL_NEUTRAL_HOST: ' .
145- str_replace(' ', '&nbsp; ', nl2br(htmlspecialchars($tmp). "\n"));
145+ str_replace(' ', '&nbsp; ', nl2br(htmlsc($tmp). "\n"));
146146 }
147147
148148 if ($prog) {
149149 echo '<pre>';
150150 echo '$progress:' . "\n";
151- echo htmlspecialchars(var_export($progress, TRUE));
151+ echo htmlsc(var_export($progress, TRUE));
152152 echo '</pre>';
153153 }
154154 }
@@ -159,7 +159,7 @@ if ($pickup) {
159159 $results = uri_pickup_normalize($results);
160160 $results = uri_pickup_normalize_pathfile($results);
161161 echo '$results:' . "\n";
162- echo htmlspecialchars(var_export($results, TRUE));
162+ echo htmlsc(var_export($results, TRUE));
163163 echo '</pre>';
164164 }
165165 ?>
--- a/spam/spam.php
+++ b/spam/spam.php
@@ -1,5 +1,5 @@
11 <?php
2-// $Id: spam.php,v 1.219 2009/01/04 08:56:07 henoheno Exp $
2+// $Id: spam.php,v 1.220 2011/01/24 14:46:45 henoheno Exp $
33 // Copyright (C) 2006-2009 PukiWiki Developers Team
44 // License: GPL v2 or (at your option) any later version
55 //
@@ -664,7 +664,7 @@ function spam_exit($mode = '', $data = array())
664664 break;
665665 case 'dump':
666666 echo('<pre>' . "\n");
667- echo htmlspecialchars(var_export($data, TRUE));
667+ echo htmlsc(var_export($data, TRUE));
668668 echo('</pre>' . "\n");
669669 break;
670670 };
--- a/spam/spam_util.php
+++ b/spam/spam_util.php
@@ -1,5 +1,5 @@
11 <?php
2-// $Id: spam_util.php,v 1.2 2009/01/04 08:56:07 henoheno Exp $
2+// $Id: spam_util.php,v 1.3 2011/01/24 14:46:45 henoheno Exp $
33 // Copyright (C) 2006-2009 PukiWiki Developers Team
44 // License: GPL v2 or (at your option) any later version
55 //
@@ -38,6 +38,18 @@ function preg_grep_invert($pattern = '//', $input = array())
3838 // ---------------------
3939 // Utilities
4040
41+
42+if (! function_exists('htmlsc')) {
43+ // Interface with PukiWiki
44+ if (! defined('CONTENT_CHARSET')) define('CONTENT_CHARSET', 'ISO-8859-1');
45+
46+ // Sugar with default settings
47+ function htmlsc($string = '', $flags = ENT_QUOTES, $charset = CONTENT_CHARSET)
48+ {
49+ return htmlspecialchars($string, $flags, $charset); // htmlsc()
50+ }
51+}
52+
4153 // Very roughly, shrink the lines of var_export()
4254 // NOTE: If the same data exists, it must be corrupted.
4355 function var_export_shrink($expression, $return = FALSE, $ignore_numeric_keys = FALSE)
Show on old repository browser