OSDN Git Service

BugTrack2/235: Sort as string
[pukiwiki/pukiwiki.git] / lib / func.php
index 126e667..f4f13b7 100644 (file)
@@ -267,7 +267,7 @@ function do_search($word, $type = 'AND', $non_format = FALSE, $base = '')
        if (empty($pages))
                return str_replace('$1', $s_word, $_msg_notfoundresult);
 
-       ksort($pages);
+       ksort($pages, SORT_STRING);
 
        $retval = '<ul>' . "\n";
        foreach (array_keys($pages) as $page) {
@@ -294,17 +294,18 @@ function arg_check($str)
 }
 
 // Encode page-name
-function encode($key)
+function encode($str)
 {
-       return ($key == '') ? '' : strtoupper(bin2hex($key));
+       $str = strval($str);
+       return ($str == '') ? '' : strtoupper(bin2hex($str));
        // Equal to strtoupper(join('', unpack('H*0', $key)));
        // But PHP 4.3.10 says 'Warning: unpack(): Type H: outside of string in ...'
 }
 
 // Decode page name
-function decode($key)
+function decode($str)
 {
-       return pkwk_hex2bin($key);
+       return pkwk_hex2bin($str);
 }
 
 // Inversion of bin2hex()
@@ -356,14 +357,14 @@ function page_list($pages, $cmd = 'read', $withfilename = FALSE)
 
        foreach($pages as $file=>$page) {
                $r_page  = rawurlencode($page);
-               $s_page  = htmlspecialchars($page, ENT_QUOTES);
+               $s_page  = htmlsc($page, ENT_QUOTES);
                $passage = get_pg_passage($page);
 
                $str = '   <li><a href="' . $href . $r_page . '">' .
                        $s_page . '</a>' . $passage;
 
                if ($withfilename) {
-                       $s_file = htmlspecialchars($file);
+                       $s_file = htmlsc($file);
                        $str .= "\n" . '    <ul><li>' . $s_file . '</li></ul>' .
                                "\n" . '   ';
                }
@@ -382,7 +383,7 @@ function page_list($pages, $cmd = 'read', $withfilename = FALSE)
                        }
                } else {
                        $head = (preg_match('/^([A-Za-z])/', $page, $matches)) ? $matches[1] :
-                               (preg_match('/^([ -~])/', $page, $matches) ? $symbol : $other);
+                               (preg_match('/^([ -~])/', $page) ? $symbol : $other);
                }
 
                $list[$head][$page] = $str;
@@ -702,7 +703,7 @@ function csv_implode($glue, $pieces)
 }
 
 // Sugar with default settings
-function htmlsc($string = '', $flags = ENT_QUOTES, $charset = CONTENT_CHARSET)
+function htmlsc($string = '', $flags = ENT_COMPAT, $charset = CONTENT_CHARSET)
 {
        return htmlspecialchars($string, $flags, $charset);     // htmlsc()
 }