SPF/Request.pm

filter: Statementstmt 87.3% 83 / 95 Branchbran 79.5% 35 / 44 Conditioncond 53.8% 14 / 26 MC/DCmcdc 31.2% 5 / 16 Subroutinesub 87.5% 14 / 16 Podpod 83.3% 5 / 6 totaltotal 76.8% 156 / 203 CC 32 SCAR 29.2
CC
32
Cov
80%
new
30.4
new_sub_request
6.0
root_request
6.0
CRAP 18.5
« SPF/v2/Record.pm ↑ Summary SPF/Mech/A.pm »
1 #
2 # Mail::SPF::Request
3 # SPF request class.
4 #
5 # (C) 2005-2012 Julian Mehnle <julian@mehnle.net>
6 # 2005 Shevek <cpan@anarres.org>
7 # $Id: Request.pm 57 2012-01-30 08:15:31Z julian $
8 #
9 ##############################################################################
10  
11 package Mail::SPF::Request;
12  
13 =head1 NAME
14  
15 Mail::SPF::Request - SPF request class
16  
17 =head1 VERSION
18  
19 version 3.20250505
20  
21 =cut
22  
23 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 4 ▶use base 'Mail::SPF::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 4 ▶use NetAddr::IP;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 4 ▶use Mail::SPF::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 4 ▶use constant TRUE => (0 == 0);
Subroutine BEGIN: called CC=1 SCAR=0.0
33 4 ▶use constant FALSE => not TRUE;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 4 use constant versions_for_scope => {
36 helo => [1 ],
37 mfrom => [1, 2],
38 pra => [ 2]
39 4 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 4 use constant scopes_by_version => {
42 1 => ['helo', 'mfrom' ],
43 2 => [ 'mfrom', 'pra']
44 4 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 4 ▶use constant default_localpart => 'postmaster';
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 # Interface:
49 ##############################################################################
50  
51 =head1 SYNOPSIS
52  
53 use Mail::SPF;
54  
55 my $request = Mail::SPF::Request->new(
56 versions => [1, 2], # optional
57 scope => 'mfrom', # or 'helo', 'pra'
58 identity => 'fred@example.com',
59 ip_address => '192.168.0.1',
60 helo_identity # optional,
61 => 'mta.example.com' # for %{h} macro expansion
62 );
63  
64 my @versions = $request->versions;
65 my $scope = $request->scope;
66 my $authority_domain
67 = $request->authority_domain;
68 my $identity = $request->identity; # 'localpart@domain' or 'domain'
69 my $domain = $request->domain;
70 my $localpart = $request->localpart;
71 my $ip_address = $request->ip_address; # IPv4 or IPv6 address
72 my $ip_address_v6 # native IPv6 address or
73 = $request->ip_address_v6; # IPv4-mapped IPv6 address
74 my $helo_identity # additional HELO identity
75 = $request->helo_identity; # for non-HELO scopes
76  
77 my $record = $request->record;
78 # the record selected during processing of the request, may be undef
79  
80 $request->state(field => 'value');
81 my $value = $request->state('field');
82  
83 =cut
84  
85 # Implementation:
86 ##############################################################################
87  
88 =head1 DESCRIPTION
89  
90 An object of class B<Mail::SPF::Request> represents an SPF request.
91  
92 =head2 Constructors
93  
94 The following constructors are provided:
95  
96 =over
97  
98 =item B<new(%options)>: returns I<Mail::SPF::Request>
99  
100 Creates a new SPF request object. The request is considered the
101 I<root-request> for any subsequent sub-requests (see the L</new_sub_request>
102 constructor).
103  
104 %options is a list of key/value pairs representing any of the following
105 options:
106  
107 =over
108  
109 =item B<versions>
110  
111 A reference to an I<array> of I<integer>s listing the versions of SPF records
112 that may be used for the SPF check. Only those record versions that cover the
113 desired scope will actually be used. At least one applicable version must be
114 specified. For a single record version, a simple scalar may be specified
115 instead of an array-ref. Defaults to all versions that cover the desired scope
116 (see below); defaults to B<[1, 2]> for the default scope of B<'mfrom'>.
117  
118 The following versions are supported:
119  
120 =over
121  
122 =item B<1>
123  
124 Use C<v=spf1> records.
125  
126 =item B<2>
127  
128 Use C<spf2.0> records.
129  
130 =back
131  
132 I<Example>: A value of B<1> (or B<[1]>) means that only C<v=spf1> records
133 should be used for the SPF check. If at the same time a scope of B<'pra'> is
134 specified, a I<Mail::SPF::EInvalidScope> exception will be thrown as C<v=spf1>
135 records do not cover the PRA scope.
136  
137 =item B<scope>
138  
139 A string denoting the authorization scope of the identity that should be
140 checked. Defaults to B<'mfrom'>. The following scope values are supported:
141  
142 =over
143  
144 =item B<'helo'>
145  
146 The given identity is the C<HELO> parameter of an SMTP transaction (RFC 2821)
147 and should be checked against SPF records that cover the C<helo> scope
148 (C<v=spf1>). See the SPFv1 specification (RFC 4408) for the formal definition
149 of the C<HELO> scope.
150  
151 =item B<'mfrom'>
152  
153 The given identity is the C<MAIL FROM> parameter of an SMTP transaction (RFC
154 2821), and should be checked against SPF records that cover the C<mfrom> scope
155 (C<v=spf1> and C<spf2.0/mfrom>). See the SPFv1 specification (RFC 4408) for
156 the formal definition of the C<MAIL FROM> scope.
157  
158 I<Note>: In the case of an empty C<MAIL FROM> SMTP transaction parameter (C<<
159 MAIL FROM:<> >>), the identity checked will be postmaster@helo name as specified
160 in RFC 7208.
161  
162 =item B<'pra'>
163  
164 The given identity is the "Purported Responsible Address" of an internet
165 message (RFC 2822) and should be checked against SPF records that cover the
166 C<pra> scope (C<spf2.0/pra>). See the PRA specification (RFC 4407) for the
167 formal definition of the PRA scope.
168  
169 =back
170  
171 =item B<authority_domain>
172  
173 A string denoting the domain name that should be queried for sender policy
174 records. Defaults to the domain of the C<identity> option. There is usually
175 no need to specify the C<authority_domain> option.
176  
177 =item B<identity>
178  
179 I<Required>. A string denoting the sender identity whose authorization should
180 be checked. This is a domain name for the C<helo> scope, and an e-mail address
181 for the C<mfrom> and C<pra> scopes.
182  
183 I<Note>: An empty identity should not be passed, in the case of an empty
184 C<MAIL FROM> SMTP transaction parameter (C<<MAIL FROM:<> >>),
185 the identity checked will be postmaster@helo name as specified
186 in RFC 7208.
187  
188 =item B<ip_address>
189  
190 I<Required> for checks with the C<helo>, C<mfrom>, and C<pra> scopes. Either a
191 string or a I<NetAddr::IP> object denoting the IP address of the host claiming
192 the identity that is being checked. Can be either an IPv4 or an IPv6 address.
193 An IPv4-mapped IPv6 address (e.g. '::ffff:192.168.0.1') is treated as an IPv4
194 address.
195  
196 =item B<helo_identity>
197  
198 A string denoting the C<HELO> SMTP transaction parameter in the case that the
199 main identity is of a scope other than C<helo>. This identity is then used
200 merely for the expansion of C<%{h}> macros during the policy evaluation of the
201 main identity. Defaults to B<undef>, which will be expanded to B<'unknown'>.
202 If the main identity is of the C<helo> scope, this option is unused.
203  
204 =back
205  
206 =cut
207  
208 sub new {
209 18 ▶ my ($self, %options) = @_;
Subroutine new: called CC=27 SCAR=34.1
Pod documented
210  
211 # Create new object:
212 18 $self = $self->SUPER::new(%options);
213 # If the request object already has a state hash, clone its contents:
214 1 $self->{state} = { %{$self->{state}} }
215 18 ▶ if ref($self->{state}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $self->{"state"} eq "HASH" 1 17 18
216  
217 # Scope:
218 18 ▶ $self->{scope} ||= 'mfrom';
Condition100%2/2
$self->{"scope"} ||= "mfrom"
l!l
810
MC/DC100%1/1
$self->{"scope"} ||= "mfrom"
$self->{"scope"}
Truth table100%2/2
A
A= $self->{"scope"}
Aresult
11
00
219 my $versions_for_scope = $self->versions_for_scope->{$self->{scope}}
220 18 ▶ or throw Mail::SPF::EInvalidScope("Invalid scope '$self->{scope}'");
Branch: 1 branch
BranchTrueFalseTotal
my $versions_for_scope = $self->versions_for_scope->{$self->{"scope"}} or "Mail::SPF::EInvalidScope"->throw(qq[Invalid scope '$self->{"scope"}']) 1 17 18
221  
222 # Versions:
223 17 ▶ if (not defined($self->{versions})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{'versions'}) { } 9 8 17
224 # No versions specified, use all versions relevant to scope:
225 9 $self->{versions} = $versions_for_scope;
226 }
227 else {
228 8 ▶ if (not ref($self->{versions})) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $self->{'versions'}) { } 2 6 8
elsif (ref $self->{'versions'} ne 'ARRAY') { } 1 5 6
229 # Single version specified as scalar:
230 2 $self->{versions} = [$self->{versions}];
231 }
232 elsif (ref($self->{versions}) ne 'ARRAY') {
233 # Something other than scalar or array-ref specified:
234 1 throw Mail::SPF::EInvalidOptionValue(
235 "'versions' option must be string or array-ref");
236 }
237  
238 # All requested record versions must be supported:
239 my @unsupported_versions = grep(
240 (not defined($self->scopes_by_version->{$_})),
241 7 @{$self->{versions}}
242 );
243 not @unsupported_versions
244 7 ▶ or throw Mail::SPF::EInvalidOptionValue(
Branch: 1 branch
BranchTrueFalseTotal
@unsupported_versions and "Mail::SPF::EInvalidOptionValue"->throw('Unsupported record version(s) ' . join(", ", map(("'${_}'"), @unsupported_versions))) 1 6 7
245 'Unsupported record version(s) ' .
246 join(', ', map("'$_'", @unsupported_versions)));
247  
248 # Use only those record versions that are relevant to the requested scope:
249 6 my %versions_for_scope;
250 6 @versions_for_scope{@$versions_for_scope} = ();
251 6 my @versions = grep(exists($versions_for_scope{$_}), @{$self->{versions}});
252  
253 # Require at least one relevant record version that covers the scope:
254 @versions
255 or throw Mail::SPF::EInvalidScope(
256 "Invalid scope '$self->{scope}' for record version(s) " .
257 6 ▶ join(', ', @{$self->{versions}}));
Branch: 1 branch
BranchTrueFalseTotal
@versions or "Mail::SPF::EInvalidScope"->throw(qq[Invalid scope '$self->{"scope"}' for record version(s) ] . join(", ", @{$self->{"versions"};})) 1 5 6
258  
259 5 $self->{versions} = \@versions;
260 }
261  
262 # Identity:
263 defined($self->{identity})
264 14 ▶ or throw Mail::SPF::EOptionRequired("Missing required 'identity' option");
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{"identity"} or "Mail::SPF::EOptionRequired"->throw("Missing required 'identity' option") 1 13 14
265 13 ▶ if(not length($self->{identity}) and (defined $self->{helo_identity})) {
Branch: 2 branches
BranchTrueFalseTotal
if (not length $self->{'identity'} and defined $self->{'helo_identity'}) { } 0 13 13
elsif (not length $self->{'identity'}) { } 0 13 13
Condition33%1/3
not length $self->{"identity"} and defined $self->{"helo_identity"}
!ll&&!rl&&r
1300
MC/DC0%0/2
not length $self->{"identity"} and defined $self->{"helo_identity"}
not length $self->{"identity"} defined $self->{"helo_identity"}
Truth table33%1/3
not(A) and B
A= not length $self->{"identity"}B= defined $self->{"helo_identity"}
ABresult
0X0
100
111
266 # if identity is <>, try with postmaster@helo as specified in RFC 7208 section 2.4
267 0 $self->{identity} = 'postmaster@' . $self->{helo_identity};
268 } elsif(not length($self->{identity})) {
269 0 throw Mail::SPF::EInvalidOptionValue("'identity' option must not be empty without specifying HELO");
270 }
271  
272 # Extract domain and localpart from identity:
273 13 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'scope'} eq 'mfrom' || $self->{'scope'} eq 'pra' and $self->{'identity'} =~ /^(.*)@(.*?)$/) { } 9 4 13
Condition83%5/6
$self->{"scope"} eq "mfrom" || $self->{"scope"} eq "pra" and $self->{"identity"} =~ /^(.*)@(.*?)$/
!ll&&!rl&&r
229
$self->{"scope"} eq "mfrom" or $self->{"scope"} eq "pra"
l!l&&r!l&&!r
1102
MC/DC66%2/3
$self->{"scope"} eq "mfrom" || $self->{"scope"} eq "pra" and $self->{"identity"} =~ /^(.*)@(.*?)$/
$self->{"scope"} eq "mfrom" $self->{"scope"} eq "pra" $self->{"identity"} =~ /^(.*)@(.*?)$/
Truth table60%3/5
A or B and C
A= $self->{"scope"} eq "mfrom"B= $self->{"scope"} eq "pra"C= $self->{"identity"} =~ /^(.*)@(.*?)$/
ABCresult
00X0
1X00
0100
1X11
0111
274 ($self->{scope} eq 'mfrom' or $self->{scope} eq 'pra') and
275 $self->{identity} =~ /^(.*)@(.*?)$/
276 ) {
277 9 $self->{domain} = $2;
278 9 $self->{localpart} = $1;
279 }
280 else {
281 4 $self->{domain} = $self->{identity};
282 }
283 13 $self->{domain} =~ s/^(.*?)\.?$/\L$1/;
284 # Lower-case domain and remove eventual trailing dot.
285 $self->{localpart} = $self->default_localpart
286 13 ▶ if not defined($self->{localpart}) or not length($self->{localpart});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"localpart"} and length $self->{"localpart"} 4 9 13
Condition66%2/3
defined $self->{"localpart"} and length $self->{"localpart"}
!ll&&!rl&&r
409
MC/DC50%1/2
defined $self->{"localpart"} and length $self->{"localpart"}
defined $self->{"localpart"} length $self->{"localpart"}
Truth table66%2/3
A and B
A= defined $self->{"localpart"}B= length $self->{"localpart"}
ABresult
0X0
100
111
287  
288 # HELO identity:
289 13 ▶ if ($self->{scope} eq 'helo') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"scope"} eq "helo") 2 11 13
290 2 ▶ $self->{helo_identity} ||= $self->{identity};
Condition33%1/3
$self->{"helo_identity"} ||= $self->{"identity"}
l!l&&r!l&&!r
020
MC/DC0%0/2
$self->{"helo_identity"} ||= $self->{"identity"}
$self->{"helo_identity"} $self->{"identity"}
Truth table33%1/3
A ||= B
A= $self->{"helo_identity"}B= $self->{"identity"}
ABresult
1X1
011
000
291 }
292  
293 # IP address:
294 throw Mail::SPF::EOptionRequired("Missing required 'ip_address' option")
295 if grep($self->{scope} eq $_, qw(helo mfrom pra))
296 13 ▶ and not defined($self->{ip_address});
Branch: 1 branch
BranchTrueFalseTotal
if grep(($self->{"scope"} eq $_), ("helo", "mfrom", "pra")) and not defined $self->{"ip_address"} 1 12 13
Condition66%2/3
grep(($self->{"scope"} eq $_), ("helo", "mfrom", "pra")) and not defined $self->{"ip_address"}
!ll&&!rl&&r
0121
MC/DC50%1/2
grep(($self->{"scope"} eq $_), ("helo", "mfrom", "pra")) and not defined $self->{"ip_address"}
grep(($self->{"scope"} eq $_), ("helo", "mfrom", "pra")) not defined $self->{"ip_address"}
Truth table66%2/3
A and not(B)
A= grep(($self->{"scope"} eq $_), ("helo", "mfrom", "pra"))B= not defined $self->{"ip_address"}
ABresult
0X0
100
111
297  
298 # Ensure ip_address is a NetAddr::IP object:
299 12 ▶ if (not UNIVERSAL::isa($self->{ip_address}, 'NetAddr::IP')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (UNIVERSAL::isa($self->{"ip_address"}, "NetAddr::IP")) 10 2 12
300 my $ip_address = NetAddr::IP->new($self->{ip_address})
301 10 ▶ or throw Mail::SPF::EInvalidOptionValue("Invalid IP address '$self->{ip_address}'");
Branch: 1 branch
BranchTrueFalseTotal
my $ip_address = "NetAddr::IP"->new($self->{"ip_address"}) or "Mail::SPF::EInvalidOptionValue"->throw(qq[Invalid IP address '$self->{"ip_address"}']) 0 10 10
302 10 $self->{ip_address} = $ip_address;
303 }
304  
305 # Convert IPv4 address to IPv4-mapped IPv6 address:
306 12 ▶ if (Mail::SPF::Util->ipv6_address_is_ipv4_mapped($self->{ip_address})) {
Branch: 3 branches
BranchTrueFalseTotal
if ('Mail::SPF::Util'->ipv6_address_is_ipv4_mapped($self->{'ip_address'})) { } 1 11 12
elsif ($self->{'ip_address'}->version == 4) { } 11 0 11
elsif ($self->{'ip_address'}->version == 6) { } 0 0 0
307 1 $self->{ip_address_v6} = $self->{ip_address}; # Accept as IPv6 address as-is.
308 1 $self->{ip_address} = Mail::SPF::Util->ipv6_address_to_ipv4($self->{ip_address});
309 }
310 elsif ($self->{ip_address}->version == 4) {
311 11 $self->{ip_address_v6} = Mail::SPF::Util->ipv4_address_to_ipv6($self->{ip_address});
312 }
313 elsif ($self->{ip_address}->version == 6) {
314 0 $self->{ip_address_v6} = $self->{ip_address};
315 }
316 else {
317 throw Mail::SPF::EInvalidOptionValue(
318 0 "Unexpected IP address version '" . $self->{ip_address}->version . "'");
319 }
320  
321 12 return $self;
322 }
323  
324 =item B<new_sub_request(%options)>: returns I<Mail::SPF::Request>
325  
326 Must be invoked on an existing request object. Creates a new sub-request
327 object by cloning the invoked request, which is then considered the new
328 request's I<super-request>. Any specified options (see the L</new>
329 constructor) override the parameters of the super-request. There is usually no
330 need to specify any options I<besides> the C<authority_domain> option.
331  
332 =cut
333  
334 sub new_sub_request {
335 0 ▶ my ($super_request, %options) = @_;
Subroutine new_sub_request: not called CC=2 SCAR=17.9
Pod documented
336 0 ▶ UNIVERSAL::isa($super_request, __PACKAGE__)
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($super_request, __PACKAGE__) or "Mail::SPF::EInstanceMethod"->throw 0 0 0
337 or throw Mail::SPF::EInstanceMethod;
338 0 my $self = $super_request->new(%options);
339 0 $self->{super_request} = $super_request;
340 0 $self->{root_request} = $super_request->root_request;
341 0 return $self;
342 }
343  
344 =back
345  
346 =head2 Instance methods
347  
348 The following instance methods are provided:
349  
350 =over
351  
352 =item B<root_request>: returns I<Mail::SPF::Request>
353  
354 Returns the root of the request's chain of super-requests. Specifically,
355 returns the request itself if it has no super-requests.
356  
357 =cut
358  
359 sub root_request {
360 0 ▶ my ($self) = @_;
Subroutine root_request: not called CC=2 SCAR=17.9
Pod undocumented
361 # Read-only!
362 0 ▶ return $self->{root_request} || $self;
Condition0%0/3
$self->{'root_request'} || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'root_request'} || $self
$self->{'root_request'} $self
Truth table0%0/3
A || B
A= $self->{'root_request'}B= $self
ABresult
1X1
011
000
363 }
364  
365 =item B<super_request>: returns I<Mail::SPF::Request>
366  
367 Returns the super-request of the request, or B<undef> if there is none.
368  
369 =cut
370  
371 # Make read-only accessor:
372 4 __PACKAGE__->make_accessor('super_request', TRUE);
373  
374 =item B<versions>: returns I<list> of I<string>
375  
376 Returns a list of the SPF record versions that are used for request. See the
377 description of the L</new> constructor's C<versions> option.
378  
379 =cut
380  
381 sub versions {
382 5 ▶ my ($self) = @_;
Subroutine versions: called CC=1 SCAR=0.0
Pod documented
383 # Read-only!
384 5 return @{$self->{versions}};
385 }
386  
387 =item B<scope>: returns I<string>
388  
389 Returns the scope of the request. See the description of the L</new>
390 constructor's C<scope> option.
391  
392 =item B<authority_domain>: returns I<string>
393  
394 Returns the authority domain of the request. See the description of the
395 L</new> constructor's C<authority_domain> option.
396  
397 =cut
398  
399 sub authority_domain {
400 6 ▶ my ($self) = @_;
Subroutine authority_domain: called CC=2 SCAR=8.1
Pod documented
401 6 ▶ return $self->{authority_domain} || $self->{domain};
Condition33%1/3
$self->{'authority_domain'} || $self->{'domain'}
l!l&&r!l&&!r
060
MC/DC0%0/2
$self->{'authority_domain'} || $self->{'domain'}
$self->{'authority_domain'} $self->{'domain'}
Truth table33%1/3
A || B
A= $self->{'authority_domain'}B= $self->{'domain'}
ABresult
1X1
011
000
402 }
403  
404 =item B<identity>: returns I<string>
405  
406 Returns the identity of the request. See the description of the L</new>
407 constructor's C<identity> option.
408  
409 =item B<domain>: returns I<string>
410  
411 Returns the identity domain of the request. See the description of the
412 L</new> constructor's C<identity> option.
413  
414 =item B<localpart>: returns I<string>
415  
416 Returns the identity localpart of the request. See the description of the
417 L</new> constructor's C<identity> option.
418  
419 =item B<ip_address>: returns I<NetAddr::IP>
420  
421 Returns the IP address of the request as a I<NetAddr::IP> object. See the
422 description of the L</new> constructor's C<ip_address> option.
423  
424 =item B<ip_address_v6>: returns I<NetAddr::IP>
425  
426 Like the C<ip_address> method, however, an IPv4 address is returned as an
427 IPv4-mapped IPv6 address (e.g. '::ffff:192.168.0.1') to facilitate uniform
428 processing.
429  
430 =item B<helo_identity>: returns I<string>
431  
432 Returns the C<HELO> SMTP transaction parameter of the request. See the
433 description of the L</new> constructor's C<helo_identity> option.
434  
435 =cut
436  
437 # Make read-only accessors:
438 __PACKAGE__->make_accessor($_, TRUE)
439 4 foreach qw(
440 scope identity domain localpart
441 ip_address ip_address_v6 helo_identity
442 );
443  
444 =item B<record>: returns I<Mail::SPF::Record>
445  
446 Returns the SPF record selected during the processing of the request, or
447 B<undef> if there is none.
448  
449 =cut
450  
451 # Make read/write accessor:
452 4 __PACKAGE__->make_accessor('record', FALSE);
453  
454 =item B<state($field)>: returns anything
455  
456 =item B<state($field, $value)>: returns anything
457  
458 Provides an interface for storing temporary state information with the request
459 object. This is primarily meant to be used internally by I<Mail::SPF::Server>
460 and other Mail::SPF classes.
461  
462 If C<$value> is specified, stores it in a state field named C<$field>. Returns
463 the current (new) value of the state field named C<$field>. This method may be
464 used as an lvalue.
465  
466 =cut
467  
468 sub state :lvalue {
469 5 ▶ my ($self, $field, @value) = @_;
Subroutine state: called CC=3 SCAR=11.0
Pod documented
470 5 ▶ defined($field)
Branch: 1 branch
BranchTrueFalseTotal
defined $field or "Mail::SPF::EOptionRequired"->throw("Field name required") 0 5 5
471 or throw Mail::SPF::EOptionRequired('Field name required');
472 5 ▶ $self->{state}->{$field} = $value[0]
Branch: 1 branch
BranchTrueFalseTotal
if @value 2 3 5
473 if @value;
474 5 $self->{state}->{$field};
475 }
476  
477 =back
478  
479 =head1 SEE ALSO
480  
481 L<Mail::SPF>, L<Mail::SPF::Server>
482  
483 L<http://tools.ietf.org/html/rfc4408>
484  
485 For availability, support, and license information, see the README file
486 included with Mail::SPF.
487  
488 =head1 AUTHORS
489  
490 Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org>
491  
492 =cut
493  
494 4 TRUE;
« SPF/v2/Record.pm ↑ Summary SPF/Mech/A.pm »