diff -ru pukiwiki-1.4.4.orig/lib/func.php pukiwiki-1.4.4/lib/func.php --- pukiwiki-1.4.4.orig/lib/func.php 2004-08-07 00:39:52.000000000 +0900 +++ pukiwiki-1.4.4/lib/func.php 2005-01-02 14:58:11.000000000 +0900 @@ -635,6 +635,39 @@ } } +// Punycode encode +function punyencode($src) +{ + $tmp = explode('/', $src); + foreach ($tmp as $key => $value) { + if (mb_detect_encoding($value) != 'ASCII') { + $tmp[$key] = 'xn--'.idn_punycode_encode($value, ''); + } + } + $src = implode('/', $tmp); + + $src = rawurlencode($src); + + return $src; +} + +// Punycode decode +function punydecode($src) +{ + $src = rawurldecode($src); + + $tmp = explode('/', $src); + foreach ($tmp as $key => $value) { + if (strpos($value, 'xn--')===0) { + $value = str_replace('xn--', '', $value); + $tmp[$key] = idn_punycode_decode($value, ''); + } + } + $src = implode('/', $tmp); + + return $src; +} + //// Compat //// diff -ru pukiwiki-1.4.4.orig/lib/init.php pukiwiki-1.4.4/lib/init.php --- pukiwiki-1.4.4.orig/lib/init.php 2004-09-04 12:01:39.000000000 +0900 +++ pukiwiki-1.4.4/lib/init.php 2005-01-02 13:59:56.000000000 +0900 @@ -238,9 +238,12 @@ // URI を urlencode せずに入力した場合に対処する $matches = array(); foreach (explode('&', $arg) as $key_and_value) { - if (preg_match('/^([^=]+)=(.+)/', $key_and_value, $matches) && - mb_detect_encoding($matches[2]) != 'ASCII') { - $_GET[$matches[1]] = $matches[2]; + if (preg_match('/^([^=]+)=(.+)/', $key_and_value, $matches)) { + if (mb_detect_encoding($matches[2]) != 'ASCII') { + $_GET[$matches[1]] = $matches[2]; + } else { + $_GET[$matches[1]] = punydecode($matches[2]); + } } } unset($matches); @@ -297,7 +300,7 @@ $get['cmd'] = $post['cmd'] = $vars['cmd'] = 'read'; if ($arg == '') $arg = $defaultpage; - $arg = rawurldecode($arg); + $arg = punydecode($arg); $arg = strip_bracket($arg); $arg = input_filter($arg); $get['page'] = $post['page'] = $vars['page'] = $arg;