Skip to content

Commit

Permalink
Fixed issue: Missing file in zip file when downloading files uploaded…
Browse files Browse the repository at this point in the history
… by participants in responses
  • Loading branch information
c-schmitz committed Mar 15, 2020
1 parent e98f1c2 commit da9a687
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions application/helpers/sanitize_helper.php
Expand Up @@ -122,6 +122,8 @@ function sanitize_filename($filename, $force_lowercase = true, $alphanumeric = f
[{}^\~`]
~x',
'-', $filename);
// Removes smart quotes
$filename = str_replace(array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"), array('','', '', '', '-', '--','...'), $filename);
// avoids ".", ".." or ".hiddenFiles"
$filename = ltrim($filename, '.-');
// optional beautification
Expand All @@ -133,9 +135,12 @@ function sanitize_filename($filename, $force_lowercase = true, $alphanumeric = f
$filename = mb_strcut(pathinfo($filename, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($filename)).($ext ? '.'.$ext : '');
$filename = ($alphanumeric) ? preg_replace("/[^a-zA-Z0-9]/", "", $filename) : $filename;

return ($force_lowercase) ?
(function_exists('mb_strtolower')) ?
mb_strtolower($filename, 'UTF-8') : strtolower($filename) : $filename;
if ($force_lowercase) {
$filename=mb_strtolower($filename, 'UTF-8');
}
// At the end of the process there are sometimes question marks left from non-UTF-8 characters
$filename = str_replace('?', '', $filename);
return $filename;
}

/**
Expand Down

0 comments on commit da9a687

Please sign in to comment.