Bug 20564: Don't use system to unzip files
authorNick Clemens <nick@bywatersolutions.com>
Tue, 10 Jul 2018 13:48:07 +0000 (13:48 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 19 Sep 2018 13:54:26 +0000 (13:54 +0000)
To test:
1 - Setup a zip file for patron images and cover images
2 - Test each tool
3 - Get a '500 error' after upload (note images do upload and attach)
4 - Apply patch
5 - Restart all the things
6 - Test agtain, uploads should complete and results display

Signed-off-by: George Williams <george@nekls.org>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
tools/picture-upload.pl
tools/upload-cover-image.pl

index 804bd96..5f99906 100755 (executable)
@@ -115,7 +115,9 @@ if ( ( $op eq 'Upload' ) && $uploadfile ) {
     }
     close $tfh;
     if ( $filetype eq 'zip' ) {
-        unless ( system( "unzip", $tempfile, '-d', $dirname ) == 0 ) {
+        qx/unzip $tempfile -d $dirname/;
+        my $exit_code = $?;
+        unless ( $exit_code == 0 ) {
             $errors{'UZIPFAIL'} = $uploadfilename;
             $template->param( ERRORS => [ \%errors ] );
             # This error is fatal to the import, so bail out here
index 009c890..ff89afb 100755 (executable)
@@ -104,7 +104,9 @@ if ($fileID) {
     else {
         my $filename = $upload->full_path;
         my $dirname = File::Temp::tempdir( CLEANUP => 1 );
-        unless ( system( "unzip", $filename, '-d', $dirname ) == 0 ) {
+        qx/unzip $filename -d $dirname/;
+        my $exit_code = $?;
+        unless ( $exit_code == 0 ) {
             $error = 'UZIPFAIL';
         }
         else {