| 1 | # This code is part of Perl distribution Mail-Message version 4.05. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # The POD got stripped from this file by OODoc version 3.06. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # For contributors see file ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2001-2026 by Mark Overmeer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | package Mail::Message;{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | our $VERSION = '4.05'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use Log::Report 'mail-message', import => [ qw/__x error info trace/ ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use Mail::Message::Body::Multipart (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use Mail::Address (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # tests in t/55reply1r.t, demo in the examples/ directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub reply(@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reply: called CC=53 SCAR=51.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | my $body = $args{body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | my $strip = !exists $args{strip_signature} || $args{strip_signature}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!exists $args{'strip_signature'} || $args{'strip_signature'}
MC/DC50%1/2
!exists $args{'strip_signature'} || $args{'strip_signature'}
!exists $args{'strip_signature'}
$args{'strip_signature'}
Truth table66%2/3
not(A) || B
A= !exists $args{'strip_signature'}B= $args{'strip_signature'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | ▶ | my $include = $args{include} || 'INLINE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'include'} || 'INLINE'
MC/DC0%0/1
$args{'include'} || 'INLINE'
$args{'include'}
Truth table50%1/2
A
A= $args{'include'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | ▶ | if($include eq 'NO') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | { # Throw away real body. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $body //= Mail::Message::Body->new(data => ["\n[The original message is not included]\n\n"]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$body //= "Mail::Message::Body"->new("data", ["\n[The original message is not included]\n\n"])
MC/DC0%0/2
$body //= "Mail::Message::Body"->new("data", ["\n[The original message is not included]\n\n"])
$body
"Mail::Message::Body"->new("data", ["\n[The original message is not included]\n\n"])
Truth table0%0/3
A //= B
A= $bodyB= "Mail::Message::Body"->new("data", ["\n[The original message is not included]\n\n"])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ▶ | elsif($include eq 'INLINE' || $include eq 'ATTACH') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$include eq "INLINE" or $include eq "ATTACH"
MC/DC0%0/2
$include eq "INLINE" or $include eq "ATTACH"
$include eq "INLINE"
$include eq "ATTACH"
Truth table33%1/3
A or B
A= $include eq "INLINE"B= $include eq "ATTACH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | unless(defined $body) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | { # text attachment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | $body = $self->body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | ▶ | $body = $body->part(0)->body if $body->isMultipart && $body->parts==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$body->isMultipart and $body->parts == 1
MC/DC0%0/2
$body->isMultipart and $body->parts == 1
$body->isMultipart
$body->parts == 1
Truth table33%1/3
A and B
A= $body->isMultipartB= $body->parts == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | ▶ | $body = $body->nested->body if $body->isNested; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | $body | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | = $strip && ! $body->isMultipart && !$body->isBinary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ? $body->decoded->stripSignature(pattern => $args{strip_signature}, max_lines => $args{max_signature}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | ▶ | : $body->decoded; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$strip and not $body->isMultipart and not $body->isBinary
$strip and not $body->isMultipart
MC/DC33%1/3
$strip and not $body->isMultipart and not $body->isBinary
$strip
not $body->isMultipart
not $body->isBinary
Truth table50%2/4
A and not(B) and not(C)
A= $stripB= not $body->isMultipartC= not $body->isBinary
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if($include eq 'INLINE' && $body->isMultipart) { $include = 'ATTACH' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$include eq "INLINE" and $body->isMultipart
MC/DC0%0/2
$include eq "INLINE" and $body->isMultipart
$include eq "INLINE"
$body->isMultipart
Truth table33%1/3
A and B
A= $include eq "INLINE"B= $body->isMultipart
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ▶ | elsif($include eq 'INLINE' && $body->isBinary) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$include eq "INLINE" and $body->isBinary
MC/DC0%0/2
$include eq "INLINE" and $body->isBinary
$include eq "INLINE"
$body->isBinary
Truth table33%1/3
A and B
A= $include eq "INLINE"B= $body->isBinary
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | { $include = 'ATTACH'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $body = Mail::Message::Body::Multipart->new(parts => [$body]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | ▶ | if($include eq 'INLINE') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 3 | ▶ | { my $quote = defined $args{quote} ? $args{quote} : exists $args{quote} ? undef : '> '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | ▶ | if(defined $quote) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | { my $quoting = ref $quote ? $quote : sub { $quote . $_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | $body = $body->foreachLine($quoting); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | { error __x"cannot include reply source as {kind}.", kind => $include; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # Collect header info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | my $mainhead = $self->toplevel->head; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # Where it comes from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | my $from = delete $args{From}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | ▶ | unless(defined $from) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | { my @from = $self->to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | ▶ | $from = \@from if @from; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # To whom to send | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | ▶ | my $to = delete $args{To} || $mainhead->get('reply-to') || $mainhead->get('from'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
delete $args{'To'} || $mainhead->get('reply-to') || $mainhead->get('from')
delete $args{"To"} or $mainhead->get("reply-to")
MC/DC0%0/3
delete $args{'To'} || $mainhead->get('reply-to') || $mainhead->get('from')
delete $args{"To"}
$mainhead->get("reply-to")
$mainhead->get('from')
Truth table25%1/4
A or B || C
A= delete $args{"To"}B= $mainhead->get("reply-to")C= $mainhead->get('from')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 3 | ▶ | defined $to or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # Add Cc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | my $cc = delete $args{Cc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | ▶ | if(!defined $cc && $args{group_reply}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $cc and $args{"group_reply"}
MC/DC50%1/2
not defined $cc and $args{"group_reply"}
not defined $cc
$args{"group_reply"}
Truth table66%2/3
not(A) and B
A= not defined $ccB= $args{"group_reply"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | { my @cc = $self->cc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | $cc = [ $self->cc ] if @cc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # Create a subject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | my $srcsub = delete $args{Subject}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | ▶ | my $subject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | = ! defined $srcsub ? $self->replySubject($self->subject) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | : ref $srcsub ? $srcsub->($self->subject) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | : $srcsub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # Create a nice message-id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | my $msgid = delete $args{'Message-ID'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | ▶ | $msgid = "<$msgid>" if $msgid && $msgid !~ /^\s*\<.*\>\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$msgid and not $msgid =~ /^\s*\<.*\>\s*$/
MC/DC0%0/2
$msgid and not $msgid =~ /^\s*\<.*\>\s*$/
$msgid
not $msgid =~ /^\s*\<.*\>\s*$/
Truth table33%1/3
A and not(B)
A= $msgidB= not $msgid =~ /^\s*\<.*\>\s*$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # Thread information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 3 | my $origid = '<'.$self->messageId.'>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | my $refs = $mainhead->get('references'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # Prelude | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | my $prelude | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | = defined $args{prelude} ? $args{prelude} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | : exists $args{prelude} ? undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | ▶ | : [ $self->replyPrelude($to) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | $prelude = Mail::Message::Body->new(data => $prelude) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $prelude and not builtin::blessed($prelude)
MC/DC50%1/2
defined $prelude and not builtin::blessed($prelude)
defined $prelude
not builtin::blessed($prelude)
Truth table66%2/3
A and not(B)
A= defined $preludeB= not builtin::blessed($prelude)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | if defined $prelude && ! blessed $prelude; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | my $postlude = $args{postlude}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | ▶ | $postlude = Mail::Message::Body->new(data => $postlude) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $postlude and not builtin::blessed($postlude)
MC/DC0%0/2
defined $postlude and not builtin::blessed($postlude)
defined $postlude
not builtin::blessed($postlude)
Truth table66%2/3
A and not(B)
A= defined $postludeB= not builtin::blessed($postlude)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | if defined $postlude && ! blessed $postlude; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # Create the message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 3 | my $total; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if($include eq 'NO') {$total = $body} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | elsif($include eq 'INLINE') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | { my $signature = $args{signature}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | ▶ | $signature = $signature->body | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $signature and $signature->isa("Mail::Message")
MC/DC0%0/2
defined $signature and $signature->isa("Mail::Message")
defined $signature
$signature->isa("Mail::Message")
Truth table33%1/3
A and B
A= defined $signatureB= $signature->isa("Mail::Message")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | if defined $signature && $signature->isa('Mail::Message'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | ▶ | $total = $body->concatenate($prelude, $body, $postlude, (defined $signature ? "-- \n$signature" : undef)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | elsif($include eq 'ATTACH') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | { my $intro = $prelude->concatenate($prelude, ["\n", "[Your message is attached]\n"], $postlude); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $total = Mail::Message::Body::Multipart->new(parts => [ $intro, $body, $args{signature} ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3 | ▶ | my $msgtype = $args{message_type} || 'Mail::Message'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'message_type'} || 'Mail::Message'
MC/DC0%0/1
$args{'message_type'} || 'Mail::Message'
$args{'message_type'}
Truth table50%1/2
A
A= $args{'message_type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | ▶ | my $reply = $msgtype->buildFromBody( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$from || 'Undisclosed senders:;'
MC/DC0%0/1
$from || 'Undisclosed senders:;'
$from
Truth table50%1/2
A
A= $from
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | $total, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | From => $from || 'Undisclosed senders:;', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | To => $to, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | Subject => $subject, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 'In-Reply-To' => $origid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | References => ($refs ? "$refs $origid" : $origid), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | my $newhead = $reply->head; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 3 | ▶ | $newhead->set(Cc => $cc) if $cc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | ▶ | $newhead->set(Bcc => delete $args{Bcc}) if $args{Bcc}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | $newhead->add($_ => $args{$_}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 3 | for sort grep /^[A-Z]/, keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # Ready | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | trace "Reply created from $origid"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | $self->label(replied => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | $reply; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # tests in t/35reply1rs.t | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | sub replySubject($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 24 | ▶ | { my ($thing, $subject) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replySubject: called CC=14 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 24 | ▶ | $subject = 'your mail' unless defined $subject && length $subject; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $subject and length $subject
MC/DC100%2/2
defined $subject and length $subject
defined $subject
length $subject
Truth table100%3/3
A and B
A= defined $subjectB= length $subject
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 24 | my @subject = split /\:/, $subject; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 24 | my $re_count = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # Strip multiple Re's from the start. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 24 | ▶ | while(@subject) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 38 | ▶ | { last if $subject[0] =~ /[A-QS-Za-qs-z][A-DF-Za-df-z]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 14 | for(shift @subject) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 14 | ▶ | { while( /\bRe(?:\[\s*(\d+)\s*\]|\b)/g ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 17 | ▶ | { $re_count += ($1 // 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$1 // 1
MC/DC100%1/1
$1 // 1
$1
Truth table100%2/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # Strip multiple Re's from the end. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 24 | ▶ | if(@subject) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 24 | { for($subject[-1]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 24 | ▶ | { $re_count++ while s/\s*\(\s*(re|forw)\W*\)\s*$//i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # Create the new subject string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 24 | ▶ | my $text = (join ':', @subject) || 'your mail'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
join(':', @subject) || 'your mail'
MC/DC0%0/1
join(':', @subject) || 'your mail'
join(':', @subject)
Truth table50%1/2
A
A= join(':', @subject)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 24 | s/^\s+//, s/\s+$// for $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 24 | ▶ | $re_count==1 ? "Re: $text" : "Re[$re_count]: $text"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | sub replyPrelude($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | { my ($self, $who) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replyPrelude: called CC=9 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | $who = $who->[0] if ref $who eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | ▶ | my $user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | = ! defined $who ? undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | : ! blessed $who ? (Mail::Address->parse($who))[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | : $who->isa('Mail::Message::Field') ? ($who->addresses)[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | : $who; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | ▶ | my $from = blessed $user && $user->isa('Mail::Address') ? ($user->name || $user->address || $user->format) : 'someone'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
builtin::blessed($user) and $user->isa("Mail::Address")
$user->name or $user->address or $user->format
$user->name or $user->address
MC/DC0%0/2
builtin::blessed($user) and $user->isa("Mail::Address")
builtin::blessed($user)
$user->isa("Mail::Address")
MC/DC0%0/3
$user->name or $user->address or $user->format
$user->name
$user->address
$user->format
Truth table33%1/3
A and B
A= builtin::blessed($user)B= $user->isa("Mail::Address")
Truth table25%1/4
A or B or C
A= $user->nameB= $user->addressC= $user->format
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | my $time = gmtime $self->timestamp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | "On $time, $from wrote:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||