]> Sergey Matveev's repositories - public-inbox.git/commitdiff
mbox: do not try to create filename from empty string
authorEric Wong <e@80x24.org>
Thu, 12 Dec 2019 08:03:39 +0000 (08:03 +0000)
committerEric Wong <e@80x24.org>
Thu, 12 Dec 2019 18:55:04 +0000 (18:55 +0000)
This was causing warnings to pop up in syslogs for messages with
empty Subject headers.

lib/PublicInbox/Mbox.pm
lib/PublicInbox/MboxGz.pm

index 42cedd15f5dead4a73170094327501f12111d983..c50a118b2b6367200767ea929ba97596bd1713c5 100644 (file)
@@ -18,7 +18,7 @@ use Email::MIME::Encode;
 sub subject_fn ($) {
        my ($hdr) = @_;
        my $fn = $hdr->header('Subject');
-       return 'no-subject' unless defined($fn);
+       return 'no-subject' if (!defined($fn) || $fn eq '');
 
        # no need for full Email::MIME, here
        if ($fn =~ /=\?/) {
index 1621cff8f3f99511fa20ff91469fdc14e32126d6..ef560426a5c7e1af697c2c5eb242ea2964beac63 100644 (file)
@@ -23,7 +23,7 @@ sub response {
        my $body = $class->new($ctx, $cb);
        # http://www.iana.org/assignments/media-types/application/gzip
        my @h = qw(Content-Type application/gzip);
-       if ($fn) {
+       if (defined $fn && $fn ne '') {
                $fn = to_filename($fn);
                push @h, 'Content-Disposition', "inline; filename=$fn.mbox.gz";
        }