Skip Menu |

This queue is for tickets about the CGI-Application-PhotoGallery CPAN distribution.

Report information
The Basics
Id: 33907
Status: resolved
Priority: 0/
Queue: CGI-Application-PhotoGallery

People
Owner: Nobody in particular
Requestors: tlhackque [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.09
Fixed in: (no value)



Subject: Crash with & in filename
File not found error when filename contains "&". (Users do the darndest things!) Seems to me that the filename isn't being properly quoted, so the &secondpartoffilename is being parsed as a query string parameter. Diagnosis: So, filename a&b.jpg gets linked as ?mode=view&photo=a%26b.jpg But it gets processed as though it were ?mode=view&photo=a&b.jpg A couple of lines of debug in show_image prove this to be the case: my $foof = $query->param('b.jpg'); $foof = "UnDeFiNeD" if( !defined $foof ); die "DEBUG: |$foof|"; will report the empty string (not undefined). So CGI.pm isn't decoding the parameter string intended. Real example: -rw-r--r-- 1 gallery gallery 1986166 Oct 28 12:38 /home/gallery/webspace/Anthony GH 2007/Emma&Seal.jpg Produces this crash: [Sat Mar 08 05:31:35 2008] [error] [client 192.168.148.108] Error executing run mode 'full': ERROR: Cannot open /home/gallery/webspace/Anthony GH 2007/Emma: No such file or directory at /usr/lib/perl5/site_perl/5.8.8/CGI/Application/PhotoGallery.pm line 437., referer: https://gallery.litts.net/gallery.cgi?mode=view&photo=% 2FAnthony%20GH%202007%2FEmma%26Seal.jpg [Sat Mar 08 05:31:35 2008] [error] [client 192.168.148.108] at /home/gallery/cgi-bin/gallery.cgi line 17, referer: https://gallery.litts.net/gallery.cgi?mode=view&photo=%2FAnthony%20GH% 202007%2FEmma%26Seal.jpg [Sat Mar 08 05:31:35 2008] [error] [client 192.168.148.108] Premature end of script headers: gallery.cgi, referer: https://gallery.litts.net/gallery.cgi?mode=view&photo=%2FAnthony%20GH% 202007%2FEmma%26Seal.jpg But mv Emma\&Seal.jpg EmmaAndSeal.jpg resolves it. However, since users will assign arbitrary names to files, gallery needs to handle them. Also, you might want to consider sending errors to the browser - use CGI::Carp qw(fatalsToBrowser); is a minimalist way to get this, though it would be better to generate a more application-specific page for the obvious cases - like file not found on open.
I've URI escaped the filename. Version 0.11 released to CPAN.
From: tlhackque [...] yahoo.com
On Sun Mar 09 22:32:04 2008, BRICAS wrote: Show quoted text
> I've URI escaped the filename. Version 0.11 released to CPAN.
Much improved, thanks. However, it's still the case that "file not found" crashes the server with an internal error. For example, bring up a gallery (thumbnails page). Delete one of the underlying .jpgs. Click on the thumbnail. You'll get an internal server error instead of a reasonable "file not found". Here is the .log file when I deleted an image called "a&b" [Mon Mar 10 08:30:10 2008] [error] [client 192.168.148.108] Error executing run mode 'view': Can't call method "getBounds" on an undefined value at /usr/lib/perl5/site_perl/5.8.8/CGI/Application/PhotoGallery/GD.pm line 115., referer: https://gallery.litts.net/gallery.cgi?dir=% 2FAnthony%20GH%202007%2F [Mon Mar 10 08:30:10 2008] [error] [client 192.168.148.108] at /home/gallery/cgi-bin/gallery.cgi line 17, referer: https://gallery.litts.net/gallery.cgi?dir=%2FAnthony%20GH%202007%2F [Mon Mar 10 08:30:10 2008] [error] [client 192.168.148.108] Premature end of script headers: gallery.cgi, referer: https://gallery.litts.net/gallery.cgi?dir=%2FAnthony%20GH%202007%2F --------------------------------------------------------- This communication may not represent my employer's views, if any, on the matters discussed.
Subject: RE: [rt.cpan.org #33907] Resolved: Crash with & in filename
Date: Mon, 10 Mar 2008 05:33:02 -0700 (PDT)
To: bug-CGI-Application-PhotoGallery [...] rt.cpan.org
From: tlhackque <tlhackque [...] yahoo.com>
Much improved, thanks. However, it's still the case that "file not found" crashes the server with an internal error. For example, bring up a gallery (thumbnails page). Delete one of the underlying .jpgs. Click on the thumbnail. You'll get an internal server error instead of a reasonable "file not found". Here is the .log file when I deleted an image called "a&b" [Mon Mar 10 08:30:10 2008] [error] [client 192.168.148.108] Error executing run mode 'view': Can't call method "getBounds" on an undefined value at /usr/lib/perl5/site_perl/5.8.8/CGI/Application/PhotoGallery/GD.pm line 115., referer: https://gallery.litts.net/gallery.cgi?dir=%2FAnthony%20GH%202007%2F [Mon Mar 10 08:30:10 2008] [error] [client 192.168.148.108] at /home/gallery/cgi-bin/gallery.cgi line 17, referer: https://gallery.litts.net/gallery.cgi?dir=%2FAnthony%20GH%202007%2F [Mon Mar 10 08:30:10 2008] [error] [client 192.168.148.108] Premature end of script headers: gallery.cgi, referer: https://gallery.litts.net/gallery.cgi?dir=%2FAnthony%20GH%202007%2F --------------------------------------------------------- This communication may not represent my employer's views, if any, on the matters discussed. Show quoted text
-----Original Message----- From: Brian Cassidy via RT [mailto:bug-CGI-Application-PhotoGallery@rt.cpan.org] Sent: Sunday, March 09, 2008 22:32 To: tlhackque@yahoo.com Subject: [rt.cpan.org #33907] Resolved: Crash with & in filename <URL: http://rt.cpan.org/Ticket/Display.html?id=33907
>
According to our records, your request has been resolved. If you have any further questions or concerns, please respond to this message.
____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
Version 0.12 sent to CPAN.