Revisión | 9b03a9b54499eef80458f77ea3465599624a97fe (tree) |
---|---|
Tiempo | 2011-01-24 23:46:45 |
Autor | henoheno <henoheno> |
Commiter | henoheno |
htmlsc(): Just sugar for htmlspecialchars(), and a foundation
@@ -1,5 +1,5 @@ | ||
1 | 1 | <?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 $ | |
3 | 3 | // Concept-work of spam-uri metrics |
4 | 4 | // Copyright (C) 2006-2007 PukiWiki Developers Team |
5 | 5 | // License: GPL v2 or (at your option) any later version |
@@ -9,7 +9,7 @@ error_reporting(E_ALL); // Debug purpose | ||
9 | 9 | require('spam.php'); |
10 | 10 | |
11 | 11 | // 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)); | |
13 | 13 | function recursive_map($func, $array) |
14 | 14 | { |
15 | 15 | if (is_array($array)) { |
@@ -25,7 +25,7 @@ function recursive_map($func, $array) | ||
25 | 25 | |
26 | 26 | function show_form($string, $asap = FALSE, $progress = TRUE, $pickup = TRUE) |
27 | 27 | { |
28 | - $string = htmlspecialchars($string); | |
28 | + $string = htmlsc($string); | |
29 | 29 | $asap = $asap ? ' checked' : ''; |
30 | 30 | $progress = $progress ? ' checked' : ''; |
31 | 31 | $pickup = $pickup ? ' checked' : ''; |
@@ -135,20 +135,20 @@ if (! empty($progress)) { | ||
135 | 135 | $tmp = summarize_detail_badhost($progress); |
136 | 136 | if ($tmp != '') { |
137 | 137 | echo 'DETAIL_BADHOST: ' . |
138 | - str_replace(' ', ' ', nl2br(htmlspecialchars($tmp). "\n")); | |
138 | + str_replace(' ', ' ', nl2br(htmlsc($tmp). "\n")); | |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | 142 | $tmp = summarize_detail_newtral($progress); |
143 | 143 | if (! $asap && $tmp != '') { |
144 | 144 | echo 'DETAIL_NEUTRAL_HOST: ' . |
145 | - str_replace(' ', ' ', nl2br(htmlspecialchars($tmp). "\n")); | |
145 | + str_replace(' ', ' ', nl2br(htmlsc($tmp). "\n")); | |
146 | 146 | } |
147 | 147 | |
148 | 148 | if ($prog) { |
149 | 149 | echo '<pre>'; |
150 | 150 | echo '$progress:' . "\n"; |
151 | - echo htmlspecialchars(var_export($progress, TRUE)); | |
151 | + echo htmlsc(var_export($progress, TRUE)); | |
152 | 152 | echo '</pre>'; |
153 | 153 | } |
154 | 154 | } |
@@ -159,7 +159,7 @@ if ($pickup) { | ||
159 | 159 | $results = uri_pickup_normalize($results); |
160 | 160 | $results = uri_pickup_normalize_pathfile($results); |
161 | 161 | echo '$results:' . "\n"; |
162 | - echo htmlspecialchars(var_export($results, TRUE)); | |
162 | + echo htmlsc(var_export($results, TRUE)); | |
163 | 163 | echo '</pre>'; |
164 | 164 | } |
165 | 165 | ?> |
@@ -1,5 +1,5 @@ | ||
1 | 1 | <?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 $ | |
3 | 3 | // Copyright (C) 2006-2009 PukiWiki Developers Team |
4 | 4 | // License: GPL v2 or (at your option) any later version |
5 | 5 | // |
@@ -664,7 +664,7 @@ function spam_exit($mode = '', $data = array()) | ||
664 | 664 | break; |
665 | 665 | case 'dump': |
666 | 666 | echo('<pre>' . "\n"); |
667 | - echo htmlspecialchars(var_export($data, TRUE)); | |
667 | + echo htmlsc(var_export($data, TRUE)); | |
668 | 668 | echo('</pre>' . "\n"); |
669 | 669 | break; |
670 | 670 | }; |
@@ -1,5 +1,5 @@ | ||
1 | 1 | <?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 $ | |
3 | 3 | // Copyright (C) 2006-2009 PukiWiki Developers Team |
4 | 4 | // License: GPL v2 or (at your option) any later version |
5 | 5 | // |
@@ -38,6 +38,18 @@ function preg_grep_invert($pattern = '//', $input = array()) | ||
38 | 38 | // --------------------- |
39 | 39 | // Utilities |
40 | 40 | |
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 | + | |
41 | 53 | // Very roughly, shrink the lines of var_export() |
42 | 54 | // NOTE: If the same data exists, it must be corrupted. |
43 | 55 | function var_export_shrink($expression, $return = FALSE, $ignore_numeric_keys = FALSE) |