From ccf45ef91f6a2fe37da9d9401053672d4a2d0550 Mon Sep 17 00:00:00 2001 From: shish Date: Thu, 26 Jul 2007 13:11:25 +0000 Subject: [PATCH] escape / as // git-svn-id: file:///home/shish/svn/shimmie2/trunk@372 7f39781d-f577-437e-ae19-be835c7a54ca --- core/util.inc.php | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index 15ab9e40..2abecb72 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -13,7 +13,10 @@ function int_escape($input) { } function url_escape($input) { - return rawurlencode($input); + $input = str_replace('/', '//', $input); + $input = rawurlencode($input); + $input = str_replace('%2F', '/', $input); + return $input; } function sql_escape($input) { @@ -359,7 +362,36 @@ function _get_query_parts() { $path = substr($path, 1); } - return split('/', $path); + /* + * Split post/list/fate//stay_night/1 + * into post list fate/stay_night 1 + */ + /* + $parts = array(); + $n = 0; + $lastsplit = 0; + while($n<=strlen($path)) { + if( + $n == strlen($path) || + ( + $path[$n] == '/' && + ($n < strlen($path) && $path[$n+1] != '/') + && ($n > 0 && $path[$n-1] != '/') + ) + ) { + $part = substr($path, $lastsplit, $n-$lastsplit); + $part = str_replace('//', '/', $part); + $parts[] = $part; + $lastsplit = $n+1; + } + $n++; + } + */ + $path = str_replace('/', ' ', $path); + $path = str_replace(' ', '/', $path); + $parts = split(' ', $path); + + return $parts; } function _get_page_request($page) {