diff options
author | B. Watson <urchlay@slackware.uk> | 2023-05-26 05:23:29 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2023-05-26 05:23:29 -0400 |
commit | 021f7fca9d936870b20d648a1b6c0cf11ce2f709 (patch) | |
tree | c2d12ef0dd8f611e82298172cb18d27df342d11d /sbolint | |
parent | 5102c1fcea48fcdc5f9b279a67ff235c0e0921ce (diff) | |
download | sbo-maintainer-tools-021f7fca9d936870b20d648a1b6c0cf11ce2f709.tar.gz |
sbolint: handle extra dots in tarball filenames (e.g. foo.bar.tar.gz).
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') { |