Skip to content
Snippets Groups Projects
Commit 4a75df56 authored by André Noack's avatar André Noack Committed by Jan-Hendrik Willms
Browse files

Resolve ""Falsche" Verzeichnisstruktur bei Download aus Veranstaltung"

Closes #928

Merge request studip/studip!2490
parent cf09538d
No related branches found
No related tags found
No related merge requests found
...@@ -104,7 +104,7 @@ class FileArchiveManager ...@@ -104,7 +104,7 @@ class FileArchiveManager
//The URL has been fetched and we can put it //The URL has been fetched and we can put it
//in a file in the archive: //in a file in the archive:
$archive->addFromString( $archive->addFromString(
$archive_fs_path . $file_type->getFilename() . '.url', $archive_fs_path . FileManager::cleanFileName($file_type->getFilename()) . '.url',
"[InternetShortcut]\nURL={$url}\n" "[InternetShortcut]\nURL={$url}\n"
); );
//Check the file size of the archive: //Check the file size of the archive:
...@@ -119,7 +119,7 @@ class FileArchiveManager ...@@ -119,7 +119,7 @@ class FileArchiveManager
if (is_array($file_list)) { if (is_array($file_list)) {
$user = $file_type->getUser(); $user = $file_type->getUser();
$file_list[] = [ $file_list[] = [
'name' => $file_type->getFilename(), 'name' => FileManager::cleanFileName($file_type->getFilename()),
'size' => $file_type->getSize(), 'size' => $file_type->getSize(),
'first_name' => ($user instanceof User) ? $user->vorname : '', 'first_name' => ($user instanceof User) ? $user->vorname : '',
'last_name' => ($user instanceof User) ? $user->nachname : '', 'last_name' => ($user instanceof User) ? $user->nachname : '',
...@@ -144,7 +144,7 @@ class FileArchiveManager ...@@ -144,7 +144,7 @@ class FileArchiveManager
if ($path) { if ($path) {
//It is a file in the file system: //It is a file in the file system:
if (file_exists($path)) { if (file_exists($path)) {
$archive->addFile($path, $archive_fs_path . $file_type->getFilename()); $archive->addFile($path, $archive_fs_path . FileManager::cleanFileName($file_type->getFilename()));
//Check the file size of the archive: //Check the file size of the archive:
if (file_exists($archive->filename) && filesize($archive->filename) > $archive_max_size) { if (file_exists($archive->filename) && filesize($archive->filename) > $archive_max_size) {
throw new FileArchiveManagerException( throw new FileArchiveManagerException(
...@@ -160,13 +160,13 @@ class FileArchiveManager ...@@ -160,13 +160,13 @@ class FileArchiveManager
$archive_max_size = Config::get()->ZIP_DOWNLOAD_MAX_SIZE * 1024 * 1024; //1048576 bytes = 1 Mebibyte $archive_max_size = Config::get()->ZIP_DOWNLOAD_MAX_SIZE * 1024 * 1024; //1048576 bytes = 1 Mebibyte
$user = $file_type->getUser(); $user = $file_type->getUser();
$file_list[] = [ $file_list[] = [
'name' => $file_type->getFilename(), 'name' => FileManager::cleanFileName($file_type->getFilename()),
'size' => $file_type->getSize(), 'size' => $file_type->getSize(),
'first_name' => ($user instanceof User) ? $user->vorname : '', 'first_name' => ($user instanceof User) ? $user->vorname : '',
'last_name' => ($user instanceof User) ? $user->nachname : '', 'last_name' => ($user instanceof User) ? $user->nachname : '',
'downloads' => $file_type->getDownloads(), 'downloads' => $file_type->getDownloads(),
'mkdate' => date('d.m.Y H:i', $file_type->getMakeDate()), 'mkdate' => date('d.m.Y H:i', $file_type->getMakeDate()),
'path' => ($archive_fs_path . $file_type->getFilename()) 'path' => ($archive_fs_path . FileManager::cleanFileName($file_type->getFilename()))
]; ];
if (count($file_list) > $archive_max_num_files) { if (count($file_list) > $archive_max_num_files) {
$archive->unchangeAll(); $archive->unchangeAll();
...@@ -283,7 +283,7 @@ class FileArchiveManager ...@@ -283,7 +283,7 @@ class FileArchiveManager
$folder_zip_path = $archive_fs_path; $folder_zip_path = $archive_fs_path;
if ($keep_hierarchy) { if ($keep_hierarchy) {
$folder_zip_path .= $folder->name; $folder_zip_path .= FileManager::cleanFileName($folder->name);
$archive->addEmptyDir($folder_zip_path); $archive->addEmptyDir($folder_zip_path);
} }
foreach ($folder->getFiles() as $file) { foreach ($folder->getFiles() as $file) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment