OSDN Git Service

htmlsc(): Just sugar for htmlspecialchars(), and a foundation
authorhenoheno <henoheno>
Mon, 24 Jan 2011 14:46:45 +0000 (23:46 +0900)
committerhenoheno <henoheno>
Mon, 24 Jan 2011 14:46:45 +0000 (23:46 +0900)
spam/checker.php
spam/spam.php
spam/spam_util.php

index a7ad720..450276c 100644 (file)
@@ -1,5 +1,5 @@
 <?php
 <?php
-// $Id: checker.php,v 1.7 2009/01/04 05:01:34 henoheno Exp $
+// $Id: checker.php,v 1.8 2011/01/24 14:46:45 henoheno Exp $
 // Concept-work of spam-uri metrics
 // Copyright (C) 2006-2007 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 // Concept-work of spam-uri metrics
 // Copyright (C) 2006-2007 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
@@ -9,7 +9,7 @@ error_reporting(E_ALL); // Debug purpose
 require('spam.php');
 
 // Recursive array_map()
 require('spam.php');
 
 // Recursive array_map()
-// e.g. Sanitilze ALL values (Debug purpose): var_dump(recursive_map('htmlspecialchars', $array));
+// e.g. Sanitilze ALL values (Debug purpose): var_dump(recursive_map('htmlsc', $array));
 function recursive_map($func, $array)
 {
        if (is_array($array)) {
 function recursive_map($func, $array)
 {
        if (is_array($array)) {
@@ -25,7 +25,7 @@ function recursive_map($func, $array)
 
 function show_form($string, $asap = FALSE, $progress = TRUE, $pickup = TRUE)
 {
 
 function show_form($string, $asap = FALSE, $progress = TRUE, $pickup = TRUE)
 {
-       $string   = htmlspecialchars($string);
+       $string   = htmlsc($string);
        $asap     = $asap     ? ' checked' : '';
        $progress = $progress ? ' checked' : '';
        $pickup   = $pickup   ? ' checked' : '';
        $asap     = $asap     ? ' checked' : '';
        $progress = $progress ? ' checked' : '';
        $pickup   = $pickup   ? ' checked' : '';
@@ -135,20 +135,20 @@ if (! empty($progress)) {
                $tmp = summarize_detail_badhost($progress);
                if ($tmp != '') {
                        echo 'DETAIL_BADHOST: ' . 
                $tmp = summarize_detail_badhost($progress);
                if ($tmp != '') {
                        echo 'DETAIL_BADHOST: ' . 
-                               str_replace('  ', '&nbsp; ', nl2br(htmlspecialchars($tmp). "\n"));
+                               str_replace('  ', '&nbsp; ', nl2br(htmlsc($tmp). "\n"));
                }
        }
 
        $tmp = summarize_detail_newtral($progress);
        if (! $asap && $tmp != '') {
                echo 'DETAIL_NEUTRAL_HOST: ' . 
                }
        }
 
        $tmp = summarize_detail_newtral($progress);
        if (! $asap && $tmp != '') {
                echo 'DETAIL_NEUTRAL_HOST: ' . 
-                               str_replace('  ', '&nbsp; ', nl2br(htmlspecialchars($tmp). "\n"));
+                               str_replace('  ', '&nbsp; ', nl2br(htmlsc($tmp). "\n"));
        }
        
        if ($prog) {
                echo '<pre>';
                echo '$progress:' . "\n";
        }
        
        if ($prog) {
                echo '<pre>';
                echo '$progress:' . "\n";
-               echo htmlspecialchars(var_export($progress, TRUE));
+               echo htmlsc(var_export($progress, TRUE));
                echo '</pre>';
        }
 }
                echo '</pre>';
        }
 }
@@ -159,7 +159,7 @@ if ($pickup) {
        $results = uri_pickup_normalize($results);
        $results = uri_pickup_normalize_pathfile($results);
        echo '$results:' . "\n";
        $results = uri_pickup_normalize($results);
        $results = uri_pickup_normalize_pathfile($results);
        echo '$results:' . "\n";
-       echo htmlspecialchars(var_export($results, TRUE));
+       echo htmlsc(var_export($results, TRUE));
        echo '</pre>';
 }
 ?>
        echo '</pre>';
 }
 ?>
index ac41338..264c03c 100644 (file)
@@ -1,5 +1,5 @@
 <?php
 <?php
-// $Id: spam.php,v 1.219 2009/01/04 08:56:07 henoheno Exp $
+// $Id: spam.php,v 1.220 2011/01/24 14:46:45 henoheno Exp $
 // Copyright (C) 2006-2009 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 //
 // Copyright (C) 2006-2009 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 //
@@ -664,7 +664,7 @@ function spam_exit($mode = '', $data = array())
                        break;
                case 'dump':
                        echo('<pre>' . "\n");
                        break;
                case 'dump':
                        echo('<pre>' . "\n");
-                       echo htmlspecialchars(var_export($data, TRUE));
+                       echo htmlsc(var_export($data, TRUE));
                        echo('</pre>' . "\n");
                        break;
        };
                        echo('</pre>' . "\n");
                        break;
        };
index 85bb18f..083f4cf 100644 (file)
@@ -1,5 +1,5 @@
 <?php
 <?php
-// $Id: spam_util.php,v 1.2 2009/01/04 08:56:07 henoheno Exp $
+// $Id: spam_util.php,v 1.3 2011/01/24 14:46:45 henoheno Exp $
 // Copyright (C) 2006-2009 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 //
 // Copyright (C) 2006-2009 PukiWiki Developers Team
 // License: GPL v2 or (at your option) any later version
 //
@@ -38,6 +38,18 @@ function preg_grep_invert($pattern = '//', $input = array())
 // ---------------------
 // Utilities
 
 // ---------------------
 // Utilities
 
+
+if (! function_exists('htmlsc')) {
+       // Interface with PukiWiki
+       if (! defined('CONTENT_CHARSET')) define('CONTENT_CHARSET', 'ISO-8859-1');
+
+       // Sugar with default settings
+       function htmlsc($string = '', $flags = ENT_QUOTES, $charset = CONTENT_CHARSET)
+       {
+               return htmlspecialchars($string, $flags, $charset);     // htmlsc()
+       }
+}
+
 // Very roughly, shrink the lines of var_export()
 // NOTE: If the same data exists, it must be corrupted.
 function var_export_shrink($expression, $return = FALSE, $ignore_numeric_keys = FALSE)
 // Very roughly, shrink the lines of var_export()
 // NOTE: If the same data exists, it must be corrupted.
 function var_export_shrink($expression, $return = FALSE, $ignore_numeric_keys = FALSE)