Ask not what osTicket community can do for you - ask what you can do for osTicket community

Go Back   osTicket Forums > Project Tools > osTicket Bug Tracker > Bug

Issue Type Bug   Project osTicket Bug Tracker
Line breaks in allowed_filetypes breaks canUploadFileType
Causes valid extensions to be ignored, as line break is part of extension comparison
Category Unknown
Affected Version 1.6.0 rc2
Priority Unknown
Status Fixed
Fixed Version 1.6 rc4
Submitted 01-21-2008
Assigned Users peter Tags (none)

issueid=17 01-21-2008 08:37 AM
Member
Line breaks in allowed_filetypes breaks canUploadFileType
Causes valid extensions to be ignored, as line break is part of extension comparison

When entering a long string for allowed_filetypes via the Admin area, the text-area automatically inserts line breaks, which are written to the database as-is.

When $cfg->canUploadFileType($filename) is called from pipe.php, the line breaks become part of the comparison, as they're not being stripped out as part of $str=ereg_replace(' ','',$this->config['allowed_filetypes']);

Any comparison involving an extension that falls on a line-break returns FALSE, instead of TRUE

I solved this on my local copy by inserting the following line after the line quoted above:

$str=ereg_replace("/\n\r|\r\n|\n|\r/", '',$str); //remove line-breaks.

Thus, canUploadFileType() becomes:

function canUploadFileType($filename) {
$ext = preg_replace("/.*\.(.{3,4})$/", "$1", $filename);
$str=ereg_replace(' ','',$this->config['allowed_filetypes']); //remove spaces.
$str=ereg_replace("/\n\r|\r\n|\n|\r/", '',$str); //remove line-breaks.
$allowed=$str?explode(',',$str):null;
return ($ext && is_array($allowed) && in_array(".$ext",$allowed))?TRUE:FALSE;
}

I'm sure the two ereg_replace calls can be combined into something more elegant
Reply

01-21-2008 11:04 PM
Issue Changed by peter
  • Issue marked as addressed
  • User assignments modified
01-22-2008 01:51 PM
Issue Changed by peter
  • Status changed from Unconfirmed to Fixed

Issue Tools
Subscribe to this issue

All times are GMT -4. The time now is 08:55 AM.