/usr/share/perl5/Mail/Message/Head.pm is in libmail-box-perl 2.110-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | # Copyrights 2001-2014 by [Mark Overmeer].
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.01.
use strict;
use warnings;
package Mail::Message::Head;
use vars '$VERSION';
$VERSION = '2.110';
use base 'Mail::Reporter';
use Mail::Message::Head::Complete;
use Mail::Message::Field::Fast;
use Carp;
use Scalar::Util 'weaken';
use overload qq("") => 'string_unless_carp'
, bool => 'isEmpty';
# To satisfy overload in static resolving.
sub toString() { shift->load->toString }
sub string() { shift->load->string }
sub string_unless_carp()
{ my $self = shift;
return $self->toString unless (caller)[0] eq 'Carp';
(my $class = ref $self) =~ s/^Mail::Message/MM/;
"$class object";
}
#------------------------------------------
sub new(@)
{ my $class = shift;
return Mail::Message::Head::Complete->new(@_)
if $class eq __PACKAGE__;
$class->SUPER::new(@_);
}
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
$self->{MMH_field_type} = $args->{field_type}
if $args->{field_type};
$self->message($args->{message})
if defined $args->{message};
$self->{MMH_fields} = {};
$self->{MMH_order} = [];
$self->{MMH_modified} = $args->{modified} || 0;
$self;
}
sub build(@)
{ shift;
Mail::Message::Head::Complete->build(@_);
}
#------------------------------------------
sub isDelayed { 1 }
sub modified(;$)
{ my $self = shift;
return $self->isModified unless @_;
$self->{MMH_modified} = shift;
}
sub isModified() { shift->{MMH_modified} }
sub isEmpty { scalar keys %{shift->{MMH_fields}} }
sub message(;$)
{ my $self = shift;
if(@_)
{ $self->{MMH_message} = shift;
weaken($self->{MMH_message});
}
$self->{MMH_message};
}
sub orderedFields() { grep {defined $_} @{shift->{MMH_order}} }
sub knownNames() { keys %{shift->{MMH_fields}} }
#------------------------------------------
sub get($;$)
{ my $known = shift->{MMH_fields};
my $value = $known->{lc(shift)};
my $index = shift;
if(defined $index)
{ return ! defined $value ? undef
: ref $value eq 'ARRAY' ? $value->[$index]
: $index == 0 ? $value
: undef;
}
elsif(wantarray)
{ return ! defined $value ? ()
: ref $value eq 'ARRAY' ? @$value
: ($value);
}
else
{ return ! defined $value ? undef
: ref $value eq 'ARRAY' ? $value->[-1]
: $value;
}
}
sub get_all(@) { my @all = shift->get(@_) } # compatibility, force list
sub setField($$) {shift->add(@_)} # compatibility
sub study($;$)
{ my $self = shift;
return map {$_->study} $self->get(@_)
if wantarray;
my $got = $self->get(@_);
defined $got ? $got->study : undef;
}
#------------------------------------------
sub isMultipart()
{ my $type = shift->get('Content-Type', 0);
$type && scalar $type->body =~ m[^multipart/]i;
}
#------------------------------
sub read($)
{ my ($self, $parser) = @_;
my @fields = $parser->readHeader;
@$self{ qw/MMH_begin MMH_end/ } = (shift @fields, shift @fields);
my $type = $self->{MMH_field_type} || 'Mail::Message::Field::Fast';
$self->addNoRealize($type->new( @$_ ))
for @fields;
$self;
}
# Warning: fields are added in addResentGroup() as well!
sub addOrderedFields(@)
{ my $order = shift->{MMH_order};
foreach (@_)
{ push @$order, $_;
weaken( $order->[-1] );
}
@_;
}
sub load($) {shift}
sub fileLocation()
{ my $self = shift;
@$self{ qw/MMH_begin MMH_end/ };
}
sub moveLocation($)
{ my ($self, $dist) = @_;
$self->{MMH_begin} -= $dist;
$self->{MMH_end} -= $dist;
$self;
}
sub setNoRealize($)
{ my ($self, $field) = @_;
my $known = $self->{MMH_fields};
my $name = $field->name;
$self->addOrderedFields($field);
$known->{$name} = $field;
$field;
}
sub addNoRealize($)
{ my ($self, $field) = @_;
my $known = $self->{MMH_fields};
my $name = $field->name;
$self->addOrderedFields($field);
if(defined $known->{$name})
{ if(ref $known->{$name} eq 'ARRAY') { push @{$known->{$name}}, $field }
else { $known->{$name} = [ $known->{$name}, $field ] }
}
else
{ $known->{$name} = $field;
}
$field;
}
#------------------------------------------
1;
|