From d4b8980b9d2305c3004ff076a83006cc20502e56 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 22 Mar 2021 07:53:59 +0000 Subject: mbox_reader: add ->reads method to avoid nonsensical formats Relying on UNIVERSAL::can may cause internal helper methods to be used, which can lead to failures or nonsensical results. --- lib/PublicInbox/LeiInput.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/LeiInput.pm') diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm index 89585a52..776b3151 100644 --- a/lib/PublicInbox/LeiInput.pm +++ b/lib/PublicInbox/LeiInput.pm @@ -18,7 +18,7 @@ sub check_input_format ($;$) { require PublicInbox::MboxReader; return 1 if $fmt eq 'eml'; # XXX: should this handle {gz,bz2,xz}? that's currently in LeiToMail - PublicInbox::MboxReader->can($fmt) or + PublicInbox::MboxReader->reads($fmt) or return $lei->fail("--$opt_key=$fmt unrecognized"); 1; } @@ -53,7 +53,7 @@ sub prepare_inputs { if (-f $input_path) { require PublicInbox::MboxLock; require PublicInbox::MboxReader; - PublicInbox::MboxReader->can($ifmt) or return + PublicInbox::MboxReader->reads($ifmt) or return $lei->fail("$ifmt not supported"); } elsif (-d _) { require PublicInbox::MdirReader; -- cgit v1.2.3-24-ge0c7