Skip Menu |

This queue is for tickets about the Kwiki-Attachments CPAN distribution.

Report information
The Basics
Id: 18786
Status: new
Priority: 0/
Queue: Kwiki-Attachments

People
Owner: Nobody in particular
Requestors: fmerges [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.18
Fixed in: (no value)



Subject: Incorrect filename due to a Browser <-> Portability issue
The bug happens when a client upload a file with a browser that don't send the filename without path, sendind it instead with the full path (obviously this is a browser issue... but we can't say the client to use another browser...). The problem is when calling CGI->param('uploaded_file'), and afterwards the basename(). When a file is: C:\MIO\Look.pdf the File::Basename use per defect the $^0 to call the right FS type, but since the call is made from the server side, that could be an different OS than the clients one, it will fail by parsing the filename. The attached patch make use of a module which try to solve this issue. Regards, Florian PD: By the way, excellent module, but would be great to see some of the whishlist posted by the other poster...
Subject: patch-kwiki-attachments-00.18-1.patch
diff -Naur Kwiki-Attachments-0.18/lib/Kwiki/Attachments.pm Kwiki-Attachments-0.18-1/lib/Kwiki/Attachments.pm --- Kwiki-Attachments-0.18/lib/Kwiki/Attachments.pm 2005-09-11 21:13:12.000000000 +0100 +++ Kwiki-Attachments-0.18-1/lib/Kwiki/Attachments.pm 2006-04-19 15:07:42.904133002 +0100 @@ -3,8 +3,9 @@ use warnings; use Kwiki::Plugin '-Base'; use Kwiki::Installer '-base'; +use FileUpload::Filename; use File::Basename; -our $VERSION = '0.18'; +our $VERSION = '0.18-1'; const class_id => 'attachments'; const class_title => 'File Attachments'; @@ -49,8 +50,12 @@ my $page_id = $self->pages->current_id; my $skip_like = $self->config->attachments_skip; my $client_file = CGI::param('uploaded_file'); - my $file = basename($client_file); - $file =~ tr/a-zA-Z0-9.&+-/_/cs; + + my $file = FileUpload::Filename->name({ + filename => $client_file, + agent => $ENV{'HTTP_USER_AGENT'}, + }); + unless ($file){ $self->display_msg("Please specify a file to upload."); } diff -Naur Kwiki-Attachments-0.18/Makefile.PL Kwiki-Attachments-0.18-1/Makefile.PL --- Kwiki-Attachments-0.18/Makefile.PL 2005-08-16 18:46:03.000000000 +0100 +++ Kwiki-Attachments-0.18-1/Makefile.PL 2006-04-19 15:10:23.225230671 +0100 @@ -5,7 +5,10 @@ WriteMakefile( NAME => 'Kwiki::Attachments', VERSION_FROM => 'lib/Kwiki/Attachments.pm', # finds $VERSION - PREREQ_PM => { Kwiki => 0.37 }, # e.g., Module::Name => 1.1 + PREREQ_PM => { + Kwiki => 0.37, + FileUpload::Filename => 0.01, + }, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/Kwiki/Attachments.pm', # retrieve abstract from module AUTHOR => 'Sue Spence <sue_cpan@pennine.com>') : ()),