X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/2e5785907d6bca9119b1ac0bba31b2260e357613..ef08b8eceac73db5a725d6b6e37509666e7d1047:/IkiWiki/Plugin/attachment.pm diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index 84bf64390..01d0d2478 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -89,9 +89,17 @@ sub formbuilder (@) { #{{{ # This is an (apparently undocumented) way to get the name # of the temp file that CGI writes the upload to. my $tempfile=$q->tmpFileName($filename); - if (! defined $tempfile || ! length $tempfile) { - error("failed to determine tempfile name"); + # perl 5.8 needs an alternative, awful method + if ($q =~ /HASH/ && exists $q->{'.tmpfiles'}) { + foreach my $key (keys(%{$q->{'.tmpfiles'}})) { + $tempfile=$q->tmpFileName(\$key); + last if defined $tempfile && length $tempfile; + } + } + if (! defined $tempfile || ! length $tempfile) { + error("CGI::tmpFileName failed to return the uploaded file name"); + } } $filename=IkiWiki::titlepage( @@ -145,7 +153,7 @@ sub formbuilder (@) { #{{{ # even that doesn't always work, # fall back to opening the tempfile $fh=undef; - open($fh, "<", $tempfile) || error("failed to open $tempfile: $!"); + open($fh, "<", $tempfile) || error("failed to open \"$tempfile\": $!"); } } binmode($fh); @@ -378,6 +386,9 @@ sub match_virusfree ($$;@) { #{{{ waitpid $pid, 0; $SIG{PIPE}="DEFAULT"; if ($sigpipe || $?) { + if (! length $reason) { + $reason="virus checker $IkiWiki::config{virus_checker}; failed with no output"; + } return IkiWiki::FailReason->new("file seems to contain a virus ($reason)"); } else {