Skip to content

Commit

Permalink
Issue #29 Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sumeetweb authored Sep 20, 2022
1 parent b69251e commit 432ac6d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions include/file.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Below some functions are sourced from stackoverflow and github :)

function filter_filename($filename, $beautify=false) {
// sanitize filename
$filename = preg_replace(
'~
[<>:"/\\|?*]| # file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
[\x00-\x1F]| # control characters http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
[\x7F\xA0\xAD]| # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN
[#\[\]@!$&\'()+,;=]| # URI reserved https://tools.ietf.org/html/rfc3986#section-2.2
[{}^\~`] # URL unsafe characters https://www.ietf.org/rfc/rfc1738.txt
~x',
'-', $filename);
// sanitize filename // Issue #29
// $filename = preg_replace(
// '~
// [<>:"/\\|?*]| # file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
// [\x00-\x1F]| # control characters http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
// [\x7F\xA0\xAD]| # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN
// [#\[\]@!$&\'()+,;=]| # URI reserved https://tools.ietf.org/html/rfc3986#section-2.2
// [{}^\~`] # URL unsafe characters https://www.ietf.org/rfc/rfc1738.txt
// ~x',
// '-', $filename);
// avoids ".", ".." or ".hiddenFiles"
$filename = ltrim($filename, '.-');
// optional beautification
Expand Down

0 comments on commit 432ac6d

Please sign in to comment.