aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2023-05-26 05:23:29 -0400
committerB. Watson <urchlay@slackware.uk>2023-05-26 05:23:29 -0400
commit021f7fca9d936870b20d648a1b6c0cf11ce2f709 (patch)
treec2d12ef0dd8f611e82298172cb18d27df342d11d
parent5102c1fcea48fcdc5f9b279a67ff235c0e0921ce (diff)
downloadsbo-maintainer-tools-021f7fca9d936870b20d648a1b6c0cf11ce2f709.tar.gz
sbolint: handle extra dots in tarball filenames (e.g. foo.bar.tar.gz).
-rwxr-xr-xsbolint17
1 files changed, 14 insertions, 3 deletions
diff --git a/sbolint b/sbolint
index aff73de..406dd1e 100755
--- a/sbolint
+++ b/sbolint
@@ -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') {