| 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::Head::ResentGroup;{ | ||||||||||||||||||||||||||||
| 13 | 3 | our $VERSION = '4.05'; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use parent 'Mail::Message::Head::FieldGroup'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use Log::Report 'mail-message', import => [ qw// ]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use Scalar::Util qw/weaken/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use Sys::Hostname qw/hostname/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use Mail::Address (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 3 | ▶ | use Mail::Message::Field::Fast (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | #-------------------- | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # all lower cased! | ||||||||||||||||||||||||||||
| 32 | 3 | my @ordered_field_names = ( | |||||||||||||||||||||||||||
| 33 | 'return-path', 'delivered-to' , 'received', 'resent-date', | ||||||||||||||||||||||||||||
| 34 | 'resent-from', 'resent-sender', , 'resent-to', 'resent-cc', | ||||||||||||||||||||||||||||
| 35 | 'resent-bcc', 'resent-message-id' | ||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 3 | my %resent_field_names = map +($_ => 1), @ordered_field_names; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | sub init($$) | ||||||||||||||||||||||||||||
| 41 | 6 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 6 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 6 | $self->{MMHR_real} = $args->{message_head}; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 6 | ▶ | $self->set(Received => $self->createReceived) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->orderedFields and not $self->received
MC/DC0%0/2
$self->orderedFields and not $self->received
$self->orderedFields
not $self->received
Truth table33%1/3
A and not(B)
A= $self->orderedFieldsB= not $self->received
| |||||||||||||||||||||||||||||
| 48 | if $self->orderedFields && ! $self->received; | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 6 | $self; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub from($@) | ||||||||||||||||||||||||||||
| 55 | 4 | ▶ | { @_==1 and return $_[0]->resentFrom; # backwards compat | ||||||||||||||||||||||||||
|
Subroutine
from: called CC=12 SCAR=25.3
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 3 | my ($class, $from, %args) = @_; | |||||||||||||||||||||||||||
| 58 | 3 | ▶ | my $head = $from->isa('Mail::Message::Head') ? $from : $from->head; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 3 | my (@groups, $group, $return_path, $delivered_to); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 3 | foreach my $field ($head->orderedFields) | |||||||||||||||||||||||||||
| 63 | 24 | { my $name = $field->name; | |||||||||||||||||||||||||||
| 64 | 24 | ▶ | $resent_field_names{$name} or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 12 | ▶ | if($name eq 'return-path') { $return_path = $field } | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 67 | 0 | elsif($name eq 'delivered-to') { $delivered_to = $field } | |||||||||||||||||||||||||||
| 68 | elsif(substr($name, 0, 7) eq 'resent-') | ||||||||||||||||||||||||||||
| 69 | 8 | ▶ | { $group->add($field) if defined $group; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | elsif($name eq 'received') | ||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||
| 73 | 3 | $group = Mail::Message::Head::ResentGroup ->new($field, message_head => $head); | |||||||||||||||||||||||||||
| 74 | 3 | push @groups, $group; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 3 | ▶ | $group->add($delivered_to) if defined $delivered_to; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 3 | undef $delivered_to; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 3 | ▶ | $group->add($return_path) if defined $return_path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 3 | undef $return_path; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 3 | @groups; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | #-------------------- | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | sub messageHead(;$) | ||||||||||||||||||||||||||||
| 90 | 4 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
messageHead: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 4 | ▶ | @_ ? $self->{MMHR_real} = shift : $self->{MMHR_real}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | sub orderedFields() | ||||||||||||||||||||||||||||
| 96 | 14 | ▶ | { my $head = shift->head; | ||||||||||||||||||||||||||
|
Subroutine
orderedFields: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 14 | ▶ | map { $head->get($_) || () } @ordered_field_names; | ||||||||||||||||||||||||||
|
Condition66%2/3
$head->get($_) || ()
MC/DC0%0/2
$head->get($_) || ()
$head->get($_)
()
Truth table66%2/3
A || B
A= $head->get($_)B= ()
| |||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub set($;$) | ||||||||||||||||||||||||||||
| 102 | 27 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
set: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | 27 | my $field; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 27 | ▶ | if(@_==1) { $field = shift } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | else | ||||||||||||||||||||||||||||
| 107 | 15 | { my ($fn, $value) = @_; | |||||||||||||||||||||||||||
| 108 | 15 | ▶ | my $name = $resent_field_names{lc $fn} ? $fn : "Resent-$fn"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 15 | $field = Mail::Message::Field::Fast->new($name, $value); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 27 | $self->head->set($field); | |||||||||||||||||||||||||||
| 113 | 27 | $field; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 1 | ▶ | sub fields() { $_[0]->orderedFields } | ||||||||||||||||||||||||||
|
Subroutine
fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | 1 | ▶ | sub fieldNames() { map $_->Name, $_[0]->orderedFields } | ||||||||||||||||||||||||||
|
Subroutine
fieldNames: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | sub delete() | ||||||||||||||||||||||||||||
| 120 | 1 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
delete: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 121 | 1 | my $head = $self->messageHead; | |||||||||||||||||||||||||||
| 122 | 1 | $head->removeField($_) for $self->fields; | |||||||||||||||||||||||||||
| 123 | 1 | $self; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 27 | ▶ | sub add(@) { shift->set(@_) } | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub addFields(@) { $_[0]->notImplemented } | ||||||||||||||||||||||||||
|
Subroutine
addFields: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | #-------------------- | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub returnPath() { $_[0]->{MMHR_return_path} } | ||||||||||||||||||||||||||
|
Subroutine
returnPath: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub deliveredTo() { $_[0]->head->get('Delivered-To') } | ||||||||||||||||||||||||||
|
Subroutine
deliveredTo: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 6 | ▶ | sub received() { $_[0]->head->get('Received') } | ||||||||||||||||||||||||||
|
Subroutine
received: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | sub receivedTimestamp() | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | { my $received = $_[0]->received or return; | ||||||||||||||||||||||||||
|
Subroutine
receivedTimestamp: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my $comment = $received->comment or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | Mail::Message::Field->dateToTimestamp($comment); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 1 | ▶ | sub date($) { $_[0]->head->get('resent-date') } | ||||||||||||||||||||||||||
|
Subroutine
date: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | sub dateTimestamp() | ||||||||||||||||||||||||||||
| 154 | 0 | ▶ | { my $date = $_[0]->date or return; | ||||||||||||||||||||||||||
|
Subroutine
dateTimestamp: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 0 | Mail::Message::Field->dateToTimestamp($date->unfoldedBody); | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub resentFrom() | ||||||||||||||||||||||||||||
| 160 | 1 | ▶ | { my $from = $_[0]->head->get('resent-from') or return (); | ||||||||||||||||||||||||||
|
Subroutine
resentFrom: called CC=3 SCAR=12.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 1 | ▶ | wantarray ? $from->addresses : $from; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | sub sender() | ||||||||||||||||||||||||||||
| 166 | 0 | ▶ | { my $sender = $_[0]->head->get('resent-sender') or return (); | ||||||||||||||||||||||||||
|
Subroutine
sender: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 0 | ▶ | wantarray ? $sender->addresses : $sender; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | sub to() | ||||||||||||||||||||||||||||
| 172 | 0 | ▶ | { my $to = $_[0]->head->get('resent-to') or return (); | ||||||||||||||||||||||||||
|
Subroutine
to: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | wantarray ? $to->addresses : $to; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | sub cc() | ||||||||||||||||||||||||||||
| 178 | 0 | ▶ | { my $cc = $_[0]->head->get('resent-cc') or return (); | ||||||||||||||||||||||||||
|
Subroutine
cc: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 0 | ▶ | wantarray ? $cc->addresses : $cc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | sub bcc() | ||||||||||||||||||||||||||||
| 184 | 0 | ▶ | { my $bcc = $_[0]->head->get('resent-bcc') or return (); | ||||||||||||||||||||||||||
|
Subroutine
bcc: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 0 | ▶ | wantarray ? $bcc->addresses : $bcc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | sub destinations() | ||||||||||||||||||||||||||||
| 190 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
destinations: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 191 | 0 | ($self->to, $self->cc, $self->bcc); | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 2 | ▶ | sub messageId() { $_[0]->head->get('resent-message-id') } | ||||||||||||||||||||||||||
|
Subroutine
messageId: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 13 | ▶ | sub isResentGroupFieldName($) { $resent_field_names{lc $_[1]} } | ||||||||||||||||||||||||||
|
Subroutine
isResentGroupFieldName: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | #-------------------- | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 3 | my $unique_received_id = 'rc'.time; | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | sub createReceived(;$) | ||||||||||||||||||||||||||||
| 205 | 0 | ▶ | { my ($self, $domain) = @_; | ||||||||||||||||||||||||||
|
Subroutine
createReceived: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 0 | ▶ | unless(defined $domain) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | { my $sender = ($self->sender)[0] || ($self->resentFrom)[0]; | ||||||||||||||||||||||||||
|
Condition0%0/3
($self->sender)[0] || ($self->resentFrom)[0]
MC/DC0%0/2
($self->sender)[0] || ($self->resentFrom)[0]
($self->sender)[0]
($self->resentFrom)[0]
Truth table0%0/3
A || B
A= ($self->sender)[0]B= ($self->resentFrom)[0]
| |||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $domain = $sender->host if defined $sender; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | my $received | |||||||||||||||||||||||||||
| 213 | = "from $domain by ". hostname . ' with SMTP id ' . $unique_received_id++ | ||||||||||||||||||||||||||||
| 214 | . ' for ' . $self->head->get('Resent-To') # may be wrong | ||||||||||||||||||||||||||||
| 215 | . '; '. Mail::Message::Field->toDate; | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | $received; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | #-------------------- | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 3 | 1; | |||||||||||||||||||||||||||