diff options
author | Eric Wong <e@80x24.org> | 2021-03-22 07:53:59 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-03-23 00:07:12 +0000 |
commit | d4b8980b9d2305c3004ff076a83006cc20502e56 (patch) | |
tree | 9fc5aca5d117d04a4c7b7ff2f5b9a818f3b9372c /lib/PublicInbox/MboxReader.pm | |
parent | c61dc9e3b1d4e8fb0035461dced3f46853535e80 (diff) | |
download | public-inbox-d4b8980b9d2305c3004ff076a83006cc20502e56.tar.gz |
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.
Diffstat (limited to 'lib/PublicInbox/MboxReader.pm')
-rw-r--r-- | lib/PublicInbox/MboxReader.pm | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/PublicInbox/MboxReader.pm b/lib/PublicInbox/MboxReader.pm index f93c2ec6..6302d1fa 100644 --- a/lib/PublicInbox/MboxReader.pm +++ b/lib/PublicInbox/MboxReader.pm @@ -133,4 +133,9 @@ sub mboxcl2 { sub new { bless \(my $x), __PACKAGE__ } +sub reads { + my $ifmt = $_[-1]; + $ifmt =~ /\Ambox(?:rd|cl|cl2|o)\z/ ? __PACKAGE__->can($ifmt) : undef +} + 1; |