| 1 | # Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||||||||||||||||||
| 5 | # This code is part of distribution Mail-Message. Meta-POD processed with | ||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||
| 9 | package Mail::Message; | ||||||||||||||||||||||||||
| 10 | 4 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 11 | 4 | $VERSION = '3.012'; | |||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||
| 14 | 4 | ▶ | use strict; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 15 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||
| 17 | 4 | ▶ | use Mail::Box::FastScalar; | ||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||
| 20 | sub read($@) | ||||||||||||||||||||||||||
| 21 | 7 | ▶ | { my ($class, $from, %args) = @_; | ||||||||||||||||||||||||
|
Subroutine
read: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||
| 22 | 7 | my ($filename, $file); | |||||||||||||||||||||||||
| 23 | 7 | my $ref = ref $from; | |||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||
| 25 | 7 | ▶ | if(!$ref) | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 26 | 3 | { $filename = 'scalar'; | |||||||||||||||||||||||||
| 27 | 3 | $file = Mail::Box::FastScalar->new(\$from); | |||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||
| 29 | elsif($ref eq 'SCALAR') | ||||||||||||||||||||||||||
| 30 | 1 | { $filename = 'ref scalar'; | |||||||||||||||||||||||||
| 31 | 1 | $file = Mail::Box::FastScalar->new($from); | |||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||
| 33 | elsif($ref eq 'ARRAY') | ||||||||||||||||||||||||||
| 34 | 1 | { $filename = 'array of lines'; | |||||||||||||||||||||||||
| 35 | 1 | my $buffer= join '', @$from; | |||||||||||||||||||||||||
| 36 | 1 | $file = Mail::Box::FastScalar->new(\$buffer); | |||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||
| 38 | elsif($ref eq 'GLOB') | ||||||||||||||||||||||||||
| 39 | 1 | { $filename = 'file (GLOB)'; | |||||||||||||||||||||||||
| 40 | 1 | local $/; | |||||||||||||||||||||||||
| 41 | 1 | my $buffer= <$from>; | |||||||||||||||||||||||||
| 42 | 1 | $file = Mail::Box::FastScalar->new(\$buffer); | |||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||
| 44 | ▶ | elsif($ref && $from->isa('IO::Handle')) | |||||||||||||||||||||||||
|
Condition33%1/3
$ref and $from->isa("IO::Handle")
MC/DC0%0/2
$ref and $from->isa("IO::Handle")
$ref
$from->isa("IO::Handle")
Truth table33%1/3
A and B
A= $refB= $from->isa("IO::Handle")
| |||||||||||||||||||||||||||
| 45 | 1 | { $filename = 'file ('.ref($from).')'; | |||||||||||||||||||||||||
| 46 | 1 | my $buffer= join '', $from->getlines; | |||||||||||||||||||||||||
| 47 | 1 | $file = Mail::Box::FastScalar->new(\$buffer); | |||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||
| 49 | else | ||||||||||||||||||||||||||
| 50 | 0 | { $class->log(ERROR => "Cannot read from $from"); | |||||||||||||||||||||||||
| 51 | 0 | return undef; | |||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||
| 54 | my $strip_status = exists $args{strip_status_fields} | ||||||||||||||||||||||||||
| 55 | ? delete $args{strip_status_fields} | ||||||||||||||||||||||||||
| 56 | 7 | ▶ | : 1; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||
| 58 | 7 | require Mail::Box::Parser::Perl; # not parseable by C parser | |||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||
| 60 | 7 | my $parser = Mail::Box::Parser::Perl->new | |||||||||||||||||||||||||
| 61 | ( %args | ||||||||||||||||||||||||||
| 62 | , filename => $filename | ||||||||||||||||||||||||||
| 63 | , file => $file | ||||||||||||||||||||||||||
| 64 | , trusted => 1 | ||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||
| 67 | 7 | my $self = $class->new(%args); | |||||||||||||||||||||||||
| 68 | 7 | $self->readFromParser($parser, $args{body_type}); | |||||||||||||||||||||||||
| 69 | 7 | $self->addReport($parser); | |||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||
| 71 | 7 | $parser->stop; | |||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||
| 73 | 7 | my $head = $self->head; | |||||||||||||||||||||||||
| 74 | 7 | ▶ | $head->set('Message-ID' => '<'.$self->messageId.'>') | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 75 | unless $head->get('Message-ID'); | ||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||
| 77 | 7 | ▶ | $head->delete('Status', 'X-Status') if $strip_status; | ||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||
| 79 | 7 | $self; | |||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||
| 82 | 4 | 1; | |||||||||||||||||||||||||