Some people upload attachments containing invalid characters such as Blank Spaces, Apostrophes, Regional Letters etc.
In osticket 1.6 RC3 staff members are not able to download such attachments.
This quick, dirty and admittedly ugly fix takes care of this inconvenience by converting all invalid filename characters into their valid equivalents (if any).
Blank Spaces ( ) become underscores (_), Apostrophes are removed etc.
FIXING: incoming email or json/xml bases attachments
We need to edit includes/class.ticket.php at (approximately) line 723
//convert the target filename to a safe string - fix
$destname = preg_replace('/ /','_',$name);$destname = preg_replace('/ä/','ae',$destname);$destname = preg_replace('/ü/','ue',$destname);
$destname = preg_replace('/ö/','oe',$destname);$destname = preg_replace('/ß/','ss',$destname);$destname = preg_replace('/,/','',$destname);
$destname = preg_replace('/@/','',$destname);$string = "'";$destname = preg_replace('/'.$string.'/','',$destname);$destname = strtolower($destname);
//assigning the filename
$filename=rtrim($dir,'/').'/'.$rand.'_'.$destname;
And, of course we need to store the fixed filename in the database as well.
Change (approximately) line 741 to
',file_name='.db_input($destname).
FIXING: online based attached files.
Also in includes/class.ticket.php at (approximately) line 687 we need the same code to take care of online uploads of files.
//convert the target filename to a safe string - zlope.com fix
$destname = preg_replace('/ /','_',$file);$destname = preg_replace('/ä/','ae',$destname);$destname = preg_replace('/ü/','ue',$destname);
$destname = preg_replace('/ö/','oe',$destname);$destname = preg_replace('/ß/','ss',$destname);$destname = preg_replace('/,/','',$destname);
$destname = preg_replace('/@/','',$destname);$string = "'";$destname = preg_replace('/'.$string.'/','',$destname);$destname = strtolower($destname);
//assigning the filename
$filename=rtrim($dir,'/').'/'.$rand.'_'.$destname;
Here, as well, we need to store the correct (now fixed) filename in the database. Edit line 702 as follows
',file_name='.db_input($destname).
Enjoy!
...and If anyone would like to clean up this preg_replace mess, please be my guest.