Bug 8268: improve error checking
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 1 Aug 2012 14:30:45 +0000 (16:30 +0200)
committerPaul Poulain <paul.poulain@biblibre.com>
Tue, 28 Aug 2012 16:02:46 +0000 (18:02 +0200)
Valid download attempts were being denied thanks to an incorrect
regular expression. This patch fixes that, and makes it easier to
understand what's going on in the code.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
tools/export.pl

index d3ad16f..9259c50 100755 (executable)
@@ -345,7 +345,8 @@ sub download_backup {
     my $filename  = $args->{filename};
 
     return unless ( $directory && -d $directory );
-    return unless ( $filename =~ m/$extension(\.(gz|bz2|xz))?$/ && not $filename =~ m#|# );
+    return unless ( $filename =~ m/\.$extension(\.(gz|bz2|xz))?$/ );
+    return if ( $filename =~ m#/# );
     $filename = "$directory/$filename";
     return unless ( -f $filename && -r $filename );
     return unless ( open(my $dump, '<', $filename) );