Do not remove @, #, & from attached file names

This commit is contained in:
Kijin Sung 2017-01-18 00:01:49 +09:00
parent f692d223f2
commit 61a6c01d26
2 changed files with 3 additions and 2 deletions

View file

@ -16,8 +16,8 @@ class FilenameFilter
public static function clean($filename)
{
// Replace dangerous characters with safe alternatives, maintaining meaning as much as possible.
$illegal = array('\\', '/', '<', '>', '{', '}', ':', ';', '|', '"', '~', '`', '@', '#', '$', '%', '^', '&', '*', '?');
$replace = array('', '', '(', ')', '(', ')', '_', ',', '_', '', '_', '\'', '_', '_', '_', '_', '_', '_', '', '');
$illegal = array('\\', '/', '<', '>', '{', '}', ':', ';', '|', '"', '~', '`', '$', '%', '^', '*', '?');
$replace = array('', '', '(', ')', '(', ')', '_', ',', '_', '', '_', '\'', '_', '_', '_', '', '');
$filename = str_replace($illegal, $replace, $filename);
// Remove control characters.

View file

@ -12,6 +12,7 @@ class FilenameFilterTest extends \Codeception\TestCase\Test
'foo*\.bar' => 'foo.bar',
'foobar{baz}.jpg' => 'foobar(baz).jpg',
'foobar^%.docx' => 'foobar_.docx',
'foo&bar@rhymix.docx' => 'foo&bar@rhymix.docx',
// Control characters
'foobar' . chr(127) . '.gif' => 'foobar.gif',