mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-28 01:29:05 +01:00
Take some more care with filenames, trying to get Windows to handle the zips
This commit is contained in:
parent
d67745ce4e
commit
e63984884f
@ -1377,18 +1377,34 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
$base_dir = $paths[0];
|
$base_dir = $paths[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// A nice name for the user
|
// Remove 'unsafe' filename characters
|
||||||
$replace = array('/'=>'_') + self::$encode;
|
// (en.wikipedia.org/wiki/Filename#Reserved_characters_and_words)
|
||||||
$filename = $GLOBALS['egw_info']['server']['site_title'] . '_' . (
|
$replace = array(
|
||||||
|
// Linux
|
||||||
|
'/',
|
||||||
|
// Windows
|
||||||
|
'\\','?','%','*',':','|',/*'.',*/ '"','<','>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// A nice name for the user,
|
||||||
|
$filename = $GLOBALS['egw_info']['server']['site_title'] . '_' .
|
||||||
|
str_replace($replace,'_',(
|
||||||
count($files) == 1 ?
|
count($files) == 1 ?
|
||||||
// Just one file (hopefully a directory?) selected
|
// Just one file (hopefully a directory?) selected
|
||||||
self::basename($files[0]) :
|
self::basename($files[0]) :
|
||||||
// Use the lowest common directory (eg: Infolog, Open, nathan)
|
// Use the lowest common directory (eg: Infolog, Open, nathan)
|
||||||
self::basename($base_dir)
|
self::basename($base_dir)
|
||||||
) . '.zip';
|
)) . '.zip';
|
||||||
|
|
||||||
|
// Make sure basename is a dir
|
||||||
|
if(substr($base_dir, -1) != '/')
|
||||||
|
{
|
||||||
|
$base_dir .='/';
|
||||||
|
}
|
||||||
|
|
||||||
// Go into directories, find them all
|
// Go into directories, find them all
|
||||||
$files = self::find($files);
|
$files = self::find($files);
|
||||||
|
$links = array();
|
||||||
|
|
||||||
// We need to remove them _after_ we're done
|
// We need to remove them _after_ we're done
|
||||||
$tempfiles = array();
|
$tempfiles = array();
|
||||||
@ -1402,6 +1418,10 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
// Use relative paths inside zip
|
// Use relative paths inside zip
|
||||||
$_name = str_replace($base_dir, '', $addfile);
|
$_name = str_replace($base_dir, '', $addfile);
|
||||||
|
|
||||||
|
// Use safe names - replace unsafe chars, convert to ASCII (ZIP spec says CP437, but we'll try)
|
||||||
|
$path = explode('/',$_name);
|
||||||
|
$_name = implode('/',translation::convert( str_replace($replace,'_',$path),false,'ASCII//TRANSLIT'));
|
||||||
|
|
||||||
// Don't go infinite with app entries
|
// Don't go infinite with app entries
|
||||||
if(self::is_link($addfile))
|
if(self::is_link($addfile))
|
||||||
{
|
{
|
||||||
@ -1411,6 +1431,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
// Add directory - if empty, client app might not show it though
|
// Add directory - if empty, client app might not show it though
|
||||||
if(self::is_dir($addfile))
|
if(self::is_dir($addfile))
|
||||||
{
|
{
|
||||||
|
// Zip directories
|
||||||
$zip->addEmptyDir($addfile);
|
$zip->addEmptyDir($addfile);
|
||||||
}
|
}
|
||||||
else if(self::is_readable($addfile))
|
else if(self::is_readable($addfile))
|
||||||
@ -1459,7 +1480,9 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
|
|
||||||
// Stop any buffering
|
// Stop any buffering
|
||||||
while(ob_get_level() > 0)
|
while(ob_get_level() > 0)
|
||||||
|
{
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
}
|
||||||
|
|
||||||
// Stream the file to the client
|
// Stream the file to the client
|
||||||
header("Content-Type: application/zip");
|
header("Content-Type: application/zip");
|
||||||
|
Loading…
Reference in New Issue
Block a user