From 66f35e30dcea03c631a293e2341771277543b4ae Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Jul 2008 11:25:30 -0400 Subject: another try at dealing with CGI.pm problem open the temp file if all attempts to get a fd fail --- IkiWiki/Plugin/attachment.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin/attachment.pm') diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index f4f64b46a..ed1cd61fe 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -88,6 +88,10 @@ sub formbuilder (@) { #{{{ # of the temp file that CGI writes the upload to. my $tempfile=$q->tmpFileName($filename); + if (! defined $tempfile) { + error("failed to determine temp filename"); + } + $filename=IkiWiki::titlepage( IkiWiki::possibly_foolish_untaint( attachment_location($form->field('page')). @@ -136,7 +140,9 @@ sub formbuilder (@) { #{{{ # needed by old CGI versions $fh=$q->param('attachment'); if (! defined $fh || ! ref $fh) { - error("failed to get filehandle"); + # even that doesn't always work, + # fall back to opening the tempfile + open($fh, "<", $tempfile) || error("failed to open $tempfile: $!"); } } binmode($fh); -- cgit v1.2.3