From 3009a773c06e6e5d731c42b12ad82272f9706f03 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Sat, 28 Jul 2012 10:40:48 +0200 Subject: [PATCH] replaced use of basename() with utf8_basename() FS#2015 --- bin/dwpage.php | 2 +- inc/JpegMeta.php | 4 ++-- inc/Mailer.class.php | 2 +- inc/TarLib.class.php | 4 ++-- inc/ZipLib.class.php | 4 ++-- inc/actions.php | 2 +- inc/feedcreator.class.php | 4 ++-- inc/infoutils.php | 2 +- inc/io.php | 2 +- inc/media.php | 2 +- inc/pageutils.php | 2 +- inc/parser/code.php | 2 +- inc/parser/xhtml.php | 6 +++--- inc/search.php | 4 ++-- install.php | 2 +- lib/exe/fetch.php | 4 ++-- lib/exe/js.php | 2 +- lib/plugins/plugin/classes/ap_download.class.php | 8 ++++---- 18 files changed, 29 insertions(+), 29 deletions(-) diff --git a/bin/dwpage.php b/bin/dwpage.php index 211bc5a9e..bc9c0f6bb 100755 --- a/bin/dwpage.php +++ b/bin/dwpage.php @@ -241,7 +241,7 @@ switch ( $OPTS->arg(0) ) { $TARGET_FN = $OPTS->arg(2); if ( empty($TARGET_FN) ) { - $TARGET_FN = getcwd().'/'.basename($WIKI_FN); + $TARGET_FN = getcwd().'/'.utf8_basename($WIKI_FN); } if ( !file_exists(dirname($TARGET_FN)) ) { diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php index ac29bca66..ce643a7e6 100644 --- a/inc/JpegMeta.php +++ b/inc/JpegMeta.php @@ -1209,7 +1209,7 @@ class JpegMeta { function _parseFileInfo() { if (file_exists($this->_fileName) && is_file($this->_fileName)) { $this->_info['file'] = array(); - $this->_info['file']['Name'] = basename($this->_fileName); + $this->_info['file']['Name'] = utf8_basename($this->_fileName); $this->_info['file']['Path'] = fullpath($this->_fileName); $this->_info['file']['Size'] = filesize($this->_fileName); if ($this->_info['file']['Size'] < 1024) { @@ -1300,7 +1300,7 @@ class JpegMeta { } } else { $this->_info['file'] = array(); - $this->_info['file']['Name'] = basename($this->_fileName); + $this->_info['file']['Name'] = utf8_basename($this->_fileName); $this->_info['file']['Url'] = $this->_fileName; } diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index c85e61395..cbd1eb0a9 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -69,7 +69,7 @@ class Mailer { */ public function attachFile($path, $mime, $name = '', $embed = '') { if(!$name) { - $name = basename($path); + $name = utf8_basename($path); } $this->attach[] = array( diff --git a/inc/TarLib.class.php b/inc/TarLib.class.php index 36c1fee83..126604cd1 100644 --- a/inc/TarLib.class.php +++ b/inc/TarLib.class.php @@ -261,14 +261,14 @@ class TarLib { function sendClient($name = '', $archive = '', $headers = true) { if(!$name && !$this->_nomf) return -9; if(!$archive && !$this->_memdat) return -10; - if(!$name) $name = basename($this->_nomf); + if(!$name) $name = utf8_basename($this->_nomf); if($archive){ if(!file_exists($archive)) return -11; } else $decoded = $this->getDynamicArchive(); if($headers) { header('Content-Type: application/x-gtar'); - header('Content-Disposition: attachment; filename='.basename($name)); + header('Content-Disposition: attachment; filename='.utf8_basename($name)); header('Accept-Ranges: bytes'); header('Content-Length: '.($archive ? filesize($archive) : strlen($decoded))); } diff --git a/inc/ZipLib.class.php b/inc/ZipLib.class.php index cf89a40a4..918d38579 100644 --- a/inc/ZipLib.class.php +++ b/inc/ZipLib.class.php @@ -52,8 +52,8 @@ class ZipLib { $fn = $files[$i]; if(!in_Array(dirname($fn[0]),$this->dirs)) $this->add_Dir(dirname($fn[0])); - if(basename($fn[0])) - $ret[basename($fn[0])]=$this->add_File($fn[1],$fn[0],$compact); + if(utf8_basename($fn[0])) + $ret[utf8_basename($fn[0])]=$this->add_File($fn[1],$fn[0],$compact); } return $ret; } diff --git a/inc/actions.php b/inc/actions.php index fc15713d8..4356662d7 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -651,7 +651,7 @@ function act_sitemap($act) { if (is_readable($sitemap)) { // Send headers header('Content-Type: '.$mime); - header('Content-Disposition: attachment; filename='.basename($sitemap)); + header('Content-Disposition: attachment; filename='.utf8_basename($sitemap)); http_conditionalRequest(filemtime($sitemap)); diff --git a/inc/feedcreator.class.php b/inc/feedcreator.class.php index 435add6ac..ea8cc7b15 100644 --- a/inc/feedcreator.class.php +++ b/inc/feedcreator.class.php @@ -597,8 +597,8 @@ class FeedCreator extends HtmlDescribable { // HTTP redirect, some feed readers' simple HTTP implementations don't follow it //Header("Location: ".$filename); - header("Content-Type: ".$this->contentType."; charset=".$this->encoding."; filename=".basename($filename)); - header("Content-Disposition: inline; filename=".basename($filename)); + header("Content-Type: ".$this->contentType."; charset=".$this->encoding."; filename=".utf8_basename($filename)); + header("Content-Disposition: inline; filename=".utf8_basename($filename)); readfile($filename, "r"); die(); } diff --git a/inc/infoutils.php b/inc/infoutils.php index d602fc7b7..9ee1a717d 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -284,7 +284,7 @@ function msg($message,$lvl=0,$line='',$file=''){ $errors[1] = 'success'; $errors[2] = 'notify'; - if($line || $file) $message.=' ['.basename($file).':'.$line.']'; + if($line || $file) $message.=' ['.utf8_basename($file).':'.$line.']'; if(!isset($MSG)) $MSG = array(); $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); diff --git a/inc/io.php b/inc/io.php index c76d2f44c..4c6eb97df 100644 --- a/inc/io.php +++ b/inc/io.php @@ -485,7 +485,7 @@ function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=20 if (is_string($content_disposition) && preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) { - $name = basename($match[1]); + $name = utf8_basename($match[1]); } } diff --git a/inc/media.php b/inc/media.php index 43bbd2560..35112f274 100644 --- a/inc/media.php +++ b/inc/media.php @@ -189,7 +189,7 @@ function media_delete($id,$auth){ // trigger an event - MEDIA_DELETE_FILE $data['id'] = $id; - $data['name'] = basename($file); + $data['name'] = utf8_basename($file); $data['path'] = $file; $data['size'] = (@file_exists($file)) ? filesize($file) : 0; diff --git a/inc/pageutils.php b/inc/pageutils.php index 5e741c491..d6abff894 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -35,7 +35,7 @@ function getID($param='id',$clean=true){ if($param != 'id') { $relpath = 'lib/exe/'; } - $script = $conf['basedir'].$relpath.basename($_SERVER['SCRIPT_FILENAME']); + $script = $conf['basedir'].$relpath.utf8_basename($_SERVER['SCRIPT_FILENAME']); }elseif($_SERVER['PATH_INFO']){ $request = $_SERVER['PATH_INFO']; diff --git a/inc/parser/code.php b/inc/parser/code.php index ff44a4e1e..21fb0dc3c 100644 --- a/inc/parser/code.php +++ b/inc/parser/code.php @@ -19,7 +19,7 @@ class Doku_Renderer_code extends Doku_Renderer { global $INPUT; if(!$language) $language = 'txt'; if(!$filename) $filename = 'snippet.'.$language; - $filename = basename($filename); + $filename = utf8_basename($filename); if($this->_codeblock == $INPUT->str('codeblock')){ header("Content-Type: text/plain; charset=utf-8"); diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 2f09dbd4f..e18718746 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -1067,7 +1067,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // return the title of the picture if (!$title) { // just show the sourcename - $title = $this->_xmlEntities(basename(noNS($src))); + $title = $this->_xmlEntities(utf8_basename(noNS($src))); } return $title; } @@ -1096,7 +1096,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // return the title of the flash if (!$title) { // just show the sourcename - $title = basename(noNS($src)); + $title = utf8_basename(noNS($src)); } return $this->_xmlEntities($title); } @@ -1115,7 +1115,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $ret .= $this->_xmlEntities($title); }else{ // just show the sourcename - $ret .= $this->_xmlEntities(basename(noNS($src))); + $ret .= $this->_xmlEntities(utf8_basename(noNS($src))); } return $ret; diff --git a/inc/search.php b/inc/search.php index a26ae4808..a02b86b34 100644 --- a/inc/search.php +++ b/inc/search.php @@ -171,7 +171,7 @@ function search_media(&$data,$base,$file,$type,$lvl,$opts){ return false; } - $info['file'] = basename($file); + $info['file'] = utf8_basename($file); $info['size'] = filesize($base.'/'.$file); $info['mtime'] = filemtime($base.'/'.$file); $info['writable'] = is_writable($base.'/'.$file); @@ -589,7 +589,7 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ $item['open'] = $return; if($opts['meta']){ - $item['file'] = basename($file); + $item['file'] = utf8_basename($file); $item['size'] = filesize($base.'/'.$file); $item['mtime'] = filemtime($base.'/'.$file); $item['rev'] = $item['mtime']; diff --git a/install.php b/install.php index 488cf58ab..017512533 100644 --- a/install.php +++ b/install.php @@ -489,7 +489,7 @@ function check_functions(){ $ok = false; } - $funcs = explode(' ','addslashes basename call_user_func chmod copy fgets '. + $funcs = explode(' ','addslashes call_user_func chmod copy fgets '. 'file file_exists fseek flush filesize ftell fopen '. 'glob header ignore_user_abort ini_get mail mkdir '. 'ob_start opendir parse_ini_file readfile realpath '. diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 60843460e..150812b55 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -122,9 +122,9 @@ function sendFile($file,$mime,$dl,$cache){ //download or display? if($dl){ - header('Content-Disposition: attachment; filename="'.basename($file).'";'); + header('Content-Disposition: attachment; filename="'.utf8_basename($file).'";'); }else{ - header('Content-Disposition: inline; filename="'.basename($file).'";'); + header('Content-Disposition: inline; filename="'.utf8_basename($file).'";'); } //use x-sendfile header to pass the delivery to compatible webservers diff --git a/lib/exe/js.php b/lib/exe/js.php index 7c54f3e2e..f84c07709 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -143,7 +143,7 @@ function js_load($file){ // is it a include_once? if($match[1]){ - $base = basename($ifile); + $base = utf8_basename($ifile); if($loaded[$base]) continue; $loaded[$base] = true; } diff --git a/lib/plugins/plugin/classes/ap_download.class.php b/lib/plugins/plugin/classes/ap_download.class.php index b2571f632..2d5ead400 100644 --- a/lib/plugins/plugin/classes/ap_download.class.php +++ b/lib/plugins/plugin/classes/ap_download.class.php @@ -155,16 +155,16 @@ class ap_download extends ap_manage { $info['type'] = 'plugin'; $info['tmp'] = "$base/$dir"; $conf = confToHash("$base/$dir/$f"); - $info['base'] = basename($conf['base']); - if(!$info['base']) $info['base'] = basename("$base/$dir"); + $info['base'] = utf8_basename($conf['base']); + if(!$info['base']) $info['base'] = utf8_basename("$base/$dir"); $result['new'][] = $info; }elseif($f == 'template.info.txt'){ $info = array(); $info['type'] = 'template'; $info['tmp'] = "$base/$dir"; $conf = confToHash("$base/$dir/$f"); - $info['base'] = basename($conf['base']); - if(!$info['base']) $info['base'] = basename("$base/$dir"); + $info['base'] = utf8_basename($conf['base']); + if(!$info['base']) $info['base'] = utf8_basename("$base/$dir"); $result['new'][] = $info; } }else{ -- GitLab