diff options
Diffstat (limited to 'sbolint')
-rwxr-xr-x | sbolint | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -484,14 +484,25 @@ sub check_tarball_mime { ); (my $basename = $file) =~ s,.*/,,; - my (undef, $ext) = split /\./, $basename, 2; + if($basename =~ /^\./) { + log_error("$file: tarball filename begins with a . (hidden, WTF?)"); + return; + } + my $ext; + if($basename =~ /\.(tar(?:\.(?:gz|bz2|xz))?)$/) { + $ext = $1; + } else { + log_error("$file: bad tarball filename, not .tar or .tar.(gz|bz2|xz), will be rejected by upload form"); + return; + } + + warn "\$basename is \"$basename\", \$ext is \"$ext\""; + my $mime = `file --brief --mime-type $file`; chomp $mime; if(!grep { $_ eq $mime } values %types) { log_error("$file is not a tarball (mime type is '$mime')"); - } elsif(!$ext) { - log_error("$file: filename has no extension (will be rejected by upload form)"); } elsif($types{$ext} ne $mime) { log_error("$file mime type '$mime' doesn't match filename (should be $types{$ext})"); } elsif($ext ne 'tar') { |