Click here to get back home

file upload

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
file upload kalikoi 01-05-2006
| |--> Re: file upload Gunnar Hjalmars...01-05-2006
|   ---> Re: file upload Gunnar Hjalmars...01-05-2006
|     | ---> Re: file upload Gunnar Hjalmars...01-05-2006
|     |     |--> Re: file upload Gunnar Hjalmars...01-06-2006
|     |     `--> Re: file upload Martin Vorlaend...01-06-2006
|     `--> Re: file upload Gunnar Hjalmars...01-05-2006
`--> Re: file upload Gunnar Hjalmars...01-05-2006
Posted by Paul Lalli on January 5, 2006, 11:31 am
Please log in for more thread options


Gunnar Hjalmarsson wrote:
> Paul Lalli wrote:
> > kalikoi@gmail.com wrote:
> >>
> >> # Strip off WINDOZE path crap
> >> $_=$filehandle;
> >> s/.*\//;
> >> my $filename=$_;
> >
> > Yuck. perldoc File::Basename
>
> Nope. File::Basename wouldn't know from which platform the file was
> sent, would it?

Nobody *knows*. But the author of this code is clearly assuming it was
MSWin32...

#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
fileparse_set_fstype('MSWin32');
print basename('\foo\bar\baz.pm');
__END__

baz.pm

Paul Lalli



Posted by Gunnar Hjalmarsson on January 5, 2006, 9:11 pm
Please log in for more thread options


Paul Lalli wrote:
> Gunnar Hjalmarsson wrote:
>>Paul Lalli wrote:
>>>kalikoi@gmail.com wrote:
>>>>
>>>> # Strip off WINDOZE path crap
>>>> $_=$filehandle;
>>>> s/.*\//;
>>>> my $filename=$_;
>>>
>>>Yuck. perldoc File::Basename
>>
>>Nope. File::Basename wouldn't know from which platform the file was
>>sent, would it?
>
> Nobody *knows*. But the author of this code is clearly assuming it was
> MSWin32...

Well, yes, which may well be a not-very-wise assumption. Generally, when
designing a file upload request, File::Basename don't help you with that.

Please feel free to criticize the regex I'm using for the purpose in
CGI::UploadEasy:

s#.*[\]:\/]##;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


Posted by Paul Lalli on January 5, 2006, 12:20 pm
Please log in for more thread options


Gunnar Hjalmarsson wrote:
> Paul Lalli wrote:
> > Nobody *knows*. But the author of this code is clearly assuming it was
> > MSWin32...
>
> Well, yes, which may well be a not-very-wise assumption. Generally, when
> designing a file upload request, File::Basename don't help you with that.

I agree.

> Please feel free to criticize the regex I'm using for the purpose in
> CGI::UploadEasy:
>
> s#.*[\]:\/]##;

Well, obviously it would cause problems for any filename that did
happen to contain one of those characters. But really, if a user
creates a file with those characters, they deserve what they have
coming.

Out of curiousity, what type of system uses the ] character as a path
separator?

Paul Lalli



Posted by Gunnar Hjalmarsson on January 5, 2006, 11:58 pm
Please log in for more thread options


Paul Lalli wrote:
> Gunnar Hjalmarsson wrote:
>>Please feel free to criticize the regex I'm using for the purpose in
>>CGI::UploadEasy:
>>
>> s#.*[\]:\/]##;
>
> Well, obviously it would cause problems for any filename that did
> happen to contain one of those characters. But really, if a user
> creates a file with those characters, they deserve what they have
> coming.

Indeed. And in the case of file uploads, it's not critical. A failure to
correctly extract the actual filename just results in the uploaded file
be named slightly different compared to the original file.

> Out of curiousity, what type of system uses the ] character as a path
> separator?

According to the File::Basename POD: VMS. I have never seen it IRL,
which is one reason why I asked. :)

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


Posted by Jim Gibson on January 5, 2006, 4:24 pm
Please log in for more thread options



> Paul Lalli wrote:
> > Gunnar Hjalmarsson wrote:

>
> > Out of curiousity, what type of system uses the ] character as a path
> > separator?
>
> According to the File::Basename POD: VMS. I have never seen it IRL,
> which is one reason why I asked. :)

As I recall, it is a directory termination character, actually, and '.'
is the path separator. For example, a full path name might be:

[dira.dirb.dirc]filename.typ

(it's been many, many years since I worked on VMS, however).

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


Similar ThreadsPosted
file upload, multipart form, and cgi::cache April 21, 2006, 7:01 am
File::FilterFuncs almost ready to upload to CPAN. January 18, 2007, 10:22 pm
Net:TFTPd questions - Want to upload configs via TFTP July 20, 2006, 12:29 pm
Choosing a good namespace for a module to upload to CPAN July 14, 2004, 1:46 pm
install HTML::Template - Problem reading cache file / Bad file number July 24, 2004, 7:55 pm
Reading contents of an excel file from a test file May 15, 2007, 2:49 am
A do-file location: how the code inside that do-file find it? January 20, 2008, 12:32 am
DBD:mysql doesn't read mysql option file /etc/my.cnf file January 27, 2005, 11:19 pm
Win32::File August 29, 2004, 9:08 pm
SGI::FAM and File::PathConvert June 14, 2005, 10:58 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap