}
sub process_message {
- my ($msg) = @_;
+ my ($in) = @_;
+ my $msg;
my $parser = MIME::Parser->new;
$parser->decode_bodies(0);
$parser->output_to_core(1);
- if (ref $msg eq 'MIME::Entity') {
- debug 'Got MIME::Entity';
- } elsif (ref $msg eq 'IO') {
- debug 'Parsing from filehandle';
- $msg = $parser->parse($msg)
- } elsif (ref $msg eq 'SCALAR') {
- debug 'Parsing from string';
- $msg = $parser->parse_data($$msg)
- } elsif (!ref $msg) {
- debug "Parsing from file $msg";
- $msg = $parser->parse_open($msg)
- } else {
- die "Don't know how to parse $msg"
- }
+ $msg = $in if ref $in eq 'MIME::Entity';
+ $msg = $parser->parse ($in) if ref $in eq 'IO';
+ $msg = $parser->parse_data ($in) if ref $in eq 'SCALAR';
+ $msg = $parser->parse_open ($in) unless ref $in;
+ die "Don't know how to parse $in" unless $msg;
if ($msg->mime_type ne 'multipart/signed' && $msg->mime_type ne 'multipart/encrypted') {
# PGP/Inline requires decoding