Subject: | process() throws warnings in Catalyst::View::Download::CSV |
Date: | Mon, 12 May 2008 16:06:59 -0700 |
To: | bug-Catalyst-View-Download [...] rt.cpan.org |
From: | Kevin Frost <kevin_frost [...] symantec.com> |
Greetings!
I'm playing around with your Catalyst::View::Download::CSV and have
found a minor bug.
In the process() method, at line 31, an "eq" comparison is made
against a header that is very often undefined in "normal" operation,
thus throwing a warning along the lines of:
"Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/
5.8.5/Catalyst/View/Download/CSV.pm line 31."
I consider this minor as it's very easy to work around in the
subclass, but it would still be nice to have the module itself be
warning-safe. I suggest the following patch, which of course is lazy
about the possibility of a "zero" content type:
--- /usr/lib/perl5/site_perl/5.8.5/Catalyst/View/Download/
CSV.pm 2008-03-10 08:42:58.000000000 -0700
+++ CVS-FIXED.pm 2008-05-12 16:04:25.000000000 -0700
@@ -28,7 +28,8 @@
my $template = $c->stash->{template};
my $content = $self->render($c, $template, $c->stash);
- $c->res->headers->header("Content-Type" => "text/csv") if($c->res-
Show quoted text
>headers->header("Content-Type") eq "");
+ $c->res->headers->header("Content-Type" => "text/csv")
+ unless $c->res->headers->header("Content-Type");
$c->res->body( $content );
}
I'm running Perl 5.8.5 on Red Hat Enterprise Linux 4.5, and I'm pretty
sure I have version 0.04 of your module.
I also have three stylistic suggestions, which have no direct bearing
on functionality:
1) Including a $VERSION would make bug reporting easier.
2) In the Pod, please consider wrapping verbatim code lines at 78
characters; otherwise they render badly as HTML.
3) perltidy is your friend. :-)
cheers
-- kf.