only clean filename, not all path clean_up_files_in_zip

pull/2487/head
Julio 10 years ago
parent fc73328d7a
commit 2e7d58b3ac
  1. 2
      composer.json
  2. 19
      main/inc/lib/fileUpload.lib.php
  3. 4
      main/work/upload_corrections.php

@ -121,7 +121,7 @@
"aferrandini/phpqrcode": "1.0.1",
"mpdf/mpdf": "6.1.*",
"barryvdh/elfinder-builds": "2.1.0.3",
"jbroadway/urlify": "1.0.3-stable",
"jbroadway/urlify": "1.0.7-stable",
"monolog/monolog": "~1.0",
"ircmaxell/password-compat": "~1.0.4",

@ -1099,8 +1099,12 @@ function unzip_uploaded_document(
*/
function clean_up_files_in_zip($p_event, &$p_header)
{
$res = clean_up_path($p_header['filename']);
return $res;
$originalFilePath = $p_header['filename'];
$originalFileName = basename($p_header['filename']);
$modifiedFileName = clean_up_path($originalFileName);
$p_header['filename'] = str_replace($originalFileName, $modifiedFileName, $originalFilePath);
return 1;
}
/**
@ -1108,11 +1112,11 @@ function clean_up_files_in_zip($p_event, &$p_header)
* by eliminating dangerous file names and cleaning them
*
* @param string $path
* @return int
* @return string
* @see disable_dangerous_file()
* @see api_replace_dangerous_char()
*/
function clean_up_path(&$path)
function clean_up_path($path)
{
// Split the path in folders and files
$path_array = explode('/', $path);
@ -1126,7 +1130,8 @@ function clean_up_path(&$path)
// Join the "cleaned" path (modified in-place as passed by reference)
$path = implode('/', $path_array);
$res = filter_extension($path);
return $res;
return $path;
}
/**
@ -1199,7 +1204,7 @@ function filter_extension(&$filename)
* @param int $group_id
* @param int $session_id Session ID, if any
* @param int $userId creator id
*
*
* @return int id if inserted document
*/
function add_document(
@ -1545,7 +1550,7 @@ function create_unexisting_directory(
$rs = Database::query($sql);
if (Database::num_rows($rs) == 0) {
$document_id = add_document(
$_course,
$systemFolderName,

@ -96,7 +96,7 @@ if ($form->validate()) {
/* Uncompress zip file*/
// We extract using a callback function that "cleans" the path
$zip->extract(
$result = $zip->extract(
PCLZIP_OPT_PATH,
$destinationDir,
PCLZIP_CB_PRE_EXTRACT,
@ -128,7 +128,6 @@ if ($form->validate()) {
$finder = new Finder();
$finder->files()->in($destinationDir);
$table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
/** @var SplFileInfo $file */
@ -137,6 +136,7 @@ if ($form->validate()) {
$fileName = substr($fileName, 20, strlen($fileName));
$pos = strpos($fileName, '-') + 1;
$fileName = substr($fileName, $pos, strlen($fileName));
if (isset($finalResult[$fileName])) {
$workStudentId = $finalResult[$fileName];
$workStudent = get_work_data_by_id($workStudentId);

Loading…
Cancel
Save