]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
content_digest_dbg: handle empty inputs
authorEric Wong <e@80x24.org>
Fri, 28 Apr 2023 09:43:27 +0000 (09:43 +0000)
committerEric Wong <e@80x24.org>
Fri, 28 Apr 2023 22:59:01 +0000 (22:59 +0000)
It's possible that we hit messages or attachments with empty
bodies, so avoid doing a regexp match on an uninitialized variable.

lib/PublicInbox/ContentDigestDbg.pm

index 31d0f707083b496adc26f841a48744dac9d0d056..853624f13516dfb28a7c224fe062442215ddea8d 100644 (file)
@@ -11,7 +11,7 @@ sub new { bless [ PublicInbox::SHA->new(256), $_[1] ], __PACKAGE__ }
 sub add {
        $_[0]->[0]->add($_[1]);
        my @dbg = split(/^/sm, $_[1]);
-       if ($dbg[0] =~ /\A(To|Cc)\0/) { # fold excessively long lines
+       if (@dbg && $dbg[0] =~ /\A(To|Cc)\0/) { # fold excessively long lines
                @dbg = map { split(/,/s, $_) } @dbg;
        }
        print { $_[0]->[1] } Dumper(\@dbg) or die "print $!";