| 1 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | package Mail::Audit::MimeEntity; | ||||||||||||||||||||
| 3 | { | ||||||||||||||||||||
| 4 | 2 | $Mail::Audit::MimeEntity::VERSION = '2.228'; | |||||||||||||||||||
| 5 | } | ||||||||||||||||||||
| 6 | # ABSTRACT: a Mail::Internet-based Mail::Audit object | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | ▶ | use File::Path; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 2 | ▶ | use Mail::Audit::Util::Tempdir; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 2 | ▶ | use MIME::Parser; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 2 | ▶ | use MIME::Entity; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 2 | ▶ | use Mail::Audit::MailInternet; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 2 | ▶ | use parent qw(Mail::Audit MIME::Entity); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 2 | my $parser; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | my @to_rmdir; | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 1 | ▶ | sub _autotype_new { | ||||||||||||||||||
|
Subroutine
_autotype_new: called CC=6 SCAR=19.5
| |||||||||||||||||||||
| 20 | 1 | my $class = shift; | |||||||||||||||||||
| 21 | 1 | my $mailinternet = shift; | |||||||||||||||||||
| 22 | 1 | my $options = shift; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 1 | $parser = MIME::Parser->new(); | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 1 | $parser->ignore_errors(1); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 1 | my $dir; | |||||||||||||||||||
| 29 | 1 | ▶ | if ($options->{output_to_core}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 0 | $parser->output_to_core($options->{output_to_core}); | |||||||||||||||||||
| 31 | } else { | ||||||||||||||||||||
| 32 | 1 | $dir = Mail::Audit::Util::Tempdir->new; | |||||||||||||||||||
| 33 | 1 | $mailinternet->_log(3, "created temporary directory " . $dir->name); | |||||||||||||||||||
| 34 | 1 | $parser->output_under($dir->name); | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | # MIME::Parser has options like extract_nested_messages which are set via | ||||||||||||||||||||
| 38 | # option-methods. | ||||||||||||||||||||
| 39 | # we'll hand them along here so that if you call Mail::Audit(mimeoptions => | ||||||||||||||||||||
| 40 | # { foo => 1 }) | ||||||||||||||||||||
| 41 | # the corresponding parser option is set, with $parser->foo(1). | ||||||||||||||||||||
| 42 | 1 | foreach my $option (keys %$options) { | |||||||||||||||||||
| 43 | 0 | ▶ | next if $option eq "output_to_core"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 0 | ▶ | if ($parser->can($option)) { $parser->$option($options->{$option}); } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | my $self = $parser->parse_data( | ||||||||||||||||||||
| 48 | 1 | [ @{ $mailinternet->head->header }, "\n", @{ $mailinternet->body } ] | |||||||||||||||||||
| 49 | ); | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | # I am so, so sorry that this sort of thing is needed. | ||||||||||||||||||||
| 52 | # -- rjbs, 2007-06-14 | ||||||||||||||||||||
| 53 | 1 | $self->{_log} = $mailinternet->{_log}; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 1 | ▶ | unless ($options->{output_to_core}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 56 | 1 | my $output_dir = $parser->filer->output_dir; | |||||||||||||||||||
| 57 | 1 | $mailinternet->_log(3, "outputting under $output_dir"); | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | # Augh! These guts are so foul and convoluted. I feel like I might as well | ||||||||||||||||||||
| 61 | # be using guids. Whatever, this will solve the tempdir-lingers-too-long | ||||||||||||||||||||
| 62 | # problem. -- rjbs, 2006-10-31 | ||||||||||||||||||||
| 63 | 1 | $self->{'__Mail::Audit::MimeEntity/tempdir'} = $dir; | |||||||||||||||||||
| 64 | 1 | bless($self, $class); | |||||||||||||||||||
| 65 | 1 | return $self; | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | ▶ | sub parser { $parser ||= MIME::Parser->new(); } | ||||||||||||||||||
|
Subroutine
parser: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/3
$parser ||= "MIME::Parser"->new
MC/DC0%0/2
$parser ||= "MIME::Parser"->new
$parser
"MIME::Parser"->new
Truth table0%0/3
A ||= B
A= $parserB= "MIME::Parser"->new
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 1 | ▶ | sub is_mime { 1; } | ||||||||||||||||||
|
Subroutine
is_mime: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 2 | 1; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||