Unicode filenames with URL encoding
darcs-hash:20050123102905-9977f-1065a1112bfd47caed0f198b94e5226c81351b64.gz
This commit is contained in:
parent
4b282abadc
commit
49c713a33b
|
@ -206,9 +206,11 @@ function breadcrumbs(){
|
|||
* currently used to replace the colon with something else
|
||||
* on Windows systems and to have proper URL encoding
|
||||
*
|
||||
* Urlencoding is ommitted when the second parameter is false
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function idfilter($id){
|
||||
function idfilter($id,$ue=true){
|
||||
global $conf;
|
||||
if ($conf['useslash'] && $conf['userewrite']){
|
||||
$id = strtr($id,':','/');
|
||||
|
@ -216,9 +218,11 @@ function idfilter($id){
|
|||
$conf['userewrite']) {
|
||||
$id = strtr($id,':',';');
|
||||
}
|
||||
$id = urlencode($id);
|
||||
$id = str_replace('%3A',':',$id); //keep as colon
|
||||
$id = str_replace('%2F','/',$id); //keep as slash
|
||||
if($ue){
|
||||
$id = urlencode($id);
|
||||
$id = str_replace('%3A',':',$id); //keep as colon
|
||||
$id = str_replace('%2F','/',$id); //keep as slash
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
@ -440,6 +444,8 @@ function cleanID($id){
|
|||
* returns the full path to the datafile specified by ID and
|
||||
* optional revision
|
||||
*
|
||||
* The filename is URL encoded to protect Unicode chars
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function wikiFN($id,$rev=''){
|
||||
|
@ -447,16 +453,16 @@ function wikiFN($id,$rev=''){
|
|||
$id = cleanID($id);
|
||||
$id = str_replace(':','/',$id);
|
||||
if(empty($rev)){
|
||||
return $conf['datadir'].'/'.$id.'.txt';
|
||||
$fn = $conf['datadir'].'/'.$id.'.txt';
|
||||
}else{
|
||||
$fn = $conf['olddir'].'/'.$id.'.'.$rev.'.txt';
|
||||
if(!$conf['usegzip'] || @file_exists($fn)){
|
||||
//return plaintext if exists or gzip is disabled
|
||||
return $fn;
|
||||
}else{
|
||||
return $fn.'.gz';
|
||||
if($conf['usegzip'] && !@file_exists($fn)){
|
||||
//return gzip if enabled and plaintext doesn't exist
|
||||
$fn .= '.gz';
|
||||
}
|
||||
}
|
||||
$fn = utf8_encodeFN($fn);
|
||||
return $fn;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -242,7 +242,8 @@ function html_btn($name,$id,$akey,$params,$method='get'){
|
|||
|
||||
$ret = '';
|
||||
|
||||
$id = idfilter($id);
|
||||
//filter id (without urlencoding)
|
||||
$id = idfilter($id,false);
|
||||
|
||||
//make nice URLs even for buttons
|
||||
$link = getBaseURL().'/';
|
||||
|
|
|
@ -324,7 +324,8 @@ function sort_search_fulltext($a,$b){
|
|||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function pathID($path){
|
||||
$id = str_replace('/',':',$path);
|
||||
$id = utf8_decodeFN($path);
|
||||
$id = str_replace('/',':',$id);
|
||||
$id = preg_replace('#\.txt$#','',$id);
|
||||
$id = preg_replace('#^:+#','',$id);
|
||||
$id = preg_replace('#:+$#','',$id);
|
||||
|
|
24
inc/utf8.php
24
inc/utf8.php
|
@ -6,6 +6,30 @@
|
|||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
|
||||
/**
|
||||
* URL-Encode a filename to allow unicodecharacters
|
||||
*
|
||||
* Slashes are not encoded
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function utf8_encodeFN($file){
|
||||
$file = rawurlencode($file);
|
||||
$file = str_replace('%2F','/',$file);
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL-Decode a filename
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function utf8_decodeFN($file){
|
||||
$file = rawurldecode($file);
|
||||
return $file;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is a unicode aware replacement for strtolower()
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue