TinyPortal

Development => Feedback => Bugs/Errors => Topic started by: MyFSI on April 20, 2006, 05:22:28 PM

Title: Upload Bug
Post by: MyFSI on April 20, 2006, 05:22:28 PM
when uploading a file named "something.another.zip" it will give an error saying ".another.zip" is not an acceptable extension.

and if the name is "something.another.alsoanother.zip" it will consider the extension as ".another.alsoanother.zip"
Title: Re: Upload Bug
Post by: IchBin on April 21, 2006, 02:06:40 PM
Of course you know you would be better off using an underscore instead of a period to name your files until Bloc comes up with a solution.
Title: Re: Upload Bug
Post by: feline on April 21, 2006, 02:53:02 PM
In TPdlmanager.php ...

uses this:
// check the extension
$allowed=explode(',',$context['TPortal']['dl_allowed_types']);
$dlext=substr(strstr($name, '.'),1);
if(!in_array($dlext, $allowed)){
$status='wrongtype';
unlink($_FILES['tp_dluploadfile']['tmp_name']);
$error = $txt['tp-dlexterror'].':<b> <br />'.$context['TPortal']['dl_allowed_types'].'</b><br /><br />'.$txt['tp-dlexterror2'].': <b>'.$dlext.'</b>';
fatal_error($error);
}


Fel
Title: Re: Upload Bug
Post by: IchBin on April 21, 2006, 05:09:13 PM
A woman that knows how to code.... what a turn on!  :-*  :D
Title: Re: Upload Bug
Post by: G6Cad on April 21, 2006, 05:18:20 PM
 ;D
Title: Re: Upload Bug
Post by: feline on April 21, 2006, 06:29:32 PM
I'm a codewoman IchBin  :coolsmiley:
Title: Re: Upload Bug
Post by: bloc on April 21, 2006, 06:44:58 PM
Try to replace
$dlext=substr(strstr($name, '.'),1);

with
$dlext=substr(strrchr($name, '.'),1);

..in dlmanager.php.
Title: Re: Upload Bug
Post by: feline on April 21, 2006, 07:07:15 PM
That will be very complex  ;)

If you try the last dot (strrchr), myfile.tar.gz not work ..  ::)

Fel
Title: Re: Upload Bug
Post by: bloc on April 21, 2006, 08:30:59 PM
ah..darn, i forgot. :) Ok, scratch that, I need to find a better way.
Title: Re: Upload Bug
Post by: MyFSI on April 21, 2006, 10:00:40 PM
maybe you could use regular expressions to compare the end of the name with the allowed types:
"(\.zip|\.txt|\.exe|\.tar\.gz|\.rar)$ ";


$allowed=explode(',',$context['TPortal']['dl_allowed_types']);
$pattern="(.".$allowed[0];
foreach($allowed as $ext)
     $pattern.="|.".$ext;
$pattern.=")$ ";
$pattern = str_replace(".", "\.", $pattern);
if (!eregi($pattern, $name)){
$status='wrongtype';
unlink($_FILES['tp_dluploadfile']['tmp_name']);
$error = $txt['tp-dlexterror'].':<b> <br />'.$context['TPortal']['dl_allowed_types'].'</b><br /><br />'.$txt['tp-dlexterror2'].': <b>'.$dlext.'</b>';
fatal_error($error);
}


not sure about this though.
Title: Re: Upload Bug
Post by: bloc on May 01, 2006, 03:13:12 PM
Yes..but the idea was to allow any type to be displayed, so the user knows what the script interprets it as.

I think in fact keeping it will be better. If it complains you will then quickly see that it do not like dots in the name.