Message/Field/AuthResults.pm

filter: Statementstmt 94.8% 110 / 116 Branchbran 75.8% 44 / 58 Conditioncond 42.1% 8 / 19 MC/DCmcdc 10.0% 1 / 10 Subroutinesub 92.3% 12 / 13 Podpod 87.5% 7 / 8 totaltotal 81.2% 182 / 224 CC 41 SCAR 29.1
CC
41
Cov
84%
parse
31.5
produceBody
9.1
addResult
5.1
CRAP 18.4
« Message.pm ↑ Summary Message/Head/Partial.pm »
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::Field::AuthResults;{
13 28 our $VERSION = '4.05';
14 }
15  
16 28 ▶use parent 'Mail::Message::Field::Structured';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 28 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 28 ▶use Log::Report 'mail-message', import => [ qw/__x error/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 28 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 #--------------------
26  
27 #--------------------
28  
29 sub init($)
30 9 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=3 SCAR=11.0
Pod undocumented
31 9 $self->{MMFA_server} = delete $args->{server};
32 9 $self->{MMFA_version} = delete $args->{version};
33  
34 9 $self->{MMFA_results} = [];
35 9 ▶ $self->addResult($_) for @{delete $args->{results} || []};
Condition50%1/2
delete $args->{'results'} || []
l!l
09
MC/DC0%0/1
delete $args->{'results'} || []
delete $args->{'results'}
Truth table50%1/2
A
A= delete $args->{'results'}
Aresult
11
00
36  
37 9 $self->SUPER::init($args);
38 }
39  
40 sub parse($)
41 8 ▶{ my ($self, $string) = @_;
Subroutine parse: called CC=27 SCAR=34.5
Pod documented
42 8 $string =~ s/\r?\n/ /g;
43  
44 8 (undef, $string) = $self->consumeComment($string);
45 8 ▶ $self->{MMFA_server} = $string =~ s/^\s*([.\w-]*\w)// ? $1 : 'unknown';
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([.\w-]*\w)// ? : 7 1 8
46  
47 8 (undef, $string) = $self->consumeComment($string);
48 8 ▶ $self->{MMFA_version} = $string =~ s/^\s*([0-9]+)// ? $1 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([0-9]+)// ? : 3 5 8
49  
50 8 (undef, $string) = $self->consumeComment($string);
51 8 $string =~ s/^.*?\;/;/; # remove accidents
52  
53 8 my @results;
54 8 ▶ while( $string =~ s/^\s*\;// )
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*\;//) 12 8 20
55 {
56 12 (undef, $string) = $self->consumeComment($string);
57 12 ▶ if($string =~ s/^\s*none//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*none//) 3 9 12
58 3 { (undef, $string) = $self->consumeComment($string);
59 3 next;
60 }
61  
62 9 my %result;
63 9 push @results, \%result;
64  
65 9 ▶ $string =~ s/^\s*([\w-]*\w)// or next;
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([\w-]*\w)// or next 9 0 9
66 9 $result{method} = $1;
67  
68 9 (undef, $string) = $self->consumeComment($string);
69 9 ▶ if($string =~ s!^\s*/!!)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s[^\s*/][]) 1 8 9
70 1 { (undef, $string) = $self->consumeComment($string);
71 1 ▶ $result{method_version} = $1 if $string =~ s/^\s*([0-9]+)//;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ s/^\s*([0-9]+)// 1 0 1
72 }
73  
74 9 (undef, $string) = $self->consumeComment($string);
75 9 ▶ if($string =~ s/^\s*\=//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*\=//) 9 0 9
76 9 { (undef, $string) = $self->consumeComment($string);
77 9 ▶ $result{result} = $1
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ s/^\s*(\w+)// 9 0 9
78 if $string =~ s/^\s*(\w+)//;
79 }
80  
81 9 (my $comment, $string) = $self->consumeComment($string);
82 9 ▶ if($comment)
Branch: 1 branch
BranchTrueFalseTotal
if ($comment) 3 6 9
83 3 { $result{comment} = $comment;
84 3 (undef, $string) = $self->consumeComment($string);
85 }
86  
87 9 ▶ if($string =~ s/\s*reason//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\s*reason//) 2 7 9
88 2 { (undef, $string) = $self->consumeComment($string);
89 2 ▶ if($string =~ s/\s*\=//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\s*\=//) 2 0 2
90 2 { (undef, $string) = $self->consumeComment($string);
91 2 ▶ $result{reason} = $1
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'// or $string =~ s/^(\w+)// 2 0 2
Condition33%2/6
$string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'// or $string =~ s/^(\w+)//
l!l&&r!l&&!r
200
$string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'//
l!l&&r!l&&!r
200
MC/DC0%0/3
$string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'// or $string =~ s/^(\w+)//
$string =~ s/^\"([^"]*)\"// $string =~ s/^\'([^']*)\'// $string =~ s/^(\w+)//
Truth table25%1/4
A or B or C
A= $string =~ s/^\"([^"]*)\"//B= $string =~ s/^\'([^']*)\'//C= $string =~ s/^(\w+)//
ABCresult
1XX1
01X1
0011
0000
92 if $string =~ s/^\"([^"]*)\"//
93 || $string =~ s/^\'([^']*)\'//
94 || $string =~ s/^(\w+)//;
95 }
96 }
97  
98 9 ▶ while($string =~ /\S/)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\S/) 13 4 17
99 13 { (undef, $string) = $self->consumeComment($string);
100 13 ▶ last if $string =~ /^\s*\;/;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /^\s*\;/ 4 9 13
101  
102 9 ▶ my $ptype = $string =~ s/^\s*([\w-]+)// ? $1 : last;
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([\w-]+)// ? : 8 1 9
103 8 (undef, $string) = $self->consumeComment($string);
104  
105 8 my ($property, $value);
106 8 ▶ if($string =~ s/^\s*\.//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*\.//) 8 0 8
107 8 { (undef, $string) = $self->consumeComment($string);
108 8 ▶ $property = $string =~ s/^\s*([\w-]+)// ? $1 : last;
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([\w-]+)// ? : 8 0 8
109 8 (undef, $string) = $self->consumeComment($string);
110 8 ▶ if($string =~ s/^\s*\=//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*\=//) 8 0 8
111 8 { (undef, $string) = $self->consumeComment($string);
112 8 $string =~ s/^\s+//;
113 8 ▶ $string =~ s/^\"([^"]*)\"// || $string =~ s/^\'([^']*)\'// || $string =~ s/^([\w@.-]+)//
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'// or $string =~ s/^([\w\@.-]+)// or last 8 0 8
Condition33%2/6
$string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'// or $string =~ s/^([\w\@.-]+)//
l!l&&r!l&&!r
080
$string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'//
l!l&&r!l&&!r
008
MC/DC0%0/3
$string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'// or $string =~ s/^([\w\@.-]+)//
$string =~ s/^\"([^"]*)\"// $string =~ s/^\'([^']*)\'// $string =~ s/^([\w\@.-]+)//
Truth table25%1/4
A or B or C
A= $string =~ s/^\"([^"]*)\"//B= $string =~ s/^\'([^']*)\'//C= $string =~ s/^([\w\@.-]+)//
ABCresult
1XX1
01X1
0011
0000
114 or last;
115  
116 8 $value = $1;
117 }
118 }
119  
120 8 ▶ if(defined $value)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 8 0 8
121 8 { $result{"$ptype.$property"} = $value;
122 }
123 else
124 0 { $string =~ s/^.*?\;/;/g; # recover from parser problem
125 }
126 }
127 }
128 8 $self->addResult($_) for @results;
129  
130 8 $self;
131 }
132  
133 sub produceBody()
134 3 ▶{ my $self = shift;
Subroutine produceBody: called CC=9 SCAR=22.1
Pod documented
135 3 my $source = $self->server;
136 3 my $version = $self->version;
137 3 ▶ $source .= " $version" if $version!=1;
Branch: 1 branch
BranchTrueFalseTotal
if $version != 1 0 3 3
138  
139 3 my @results;
140 3 foreach my $r ($self->results)
141 3 { my $method = $r->{method};
142 $method .= "/$r->{method_version}"
143 3 ▶ if $r->{method_version} != 1;
Branch: 1 branch
BranchTrueFalseTotal
if $r->{"method_version"} != 1 1 2 3
144  
145 3 my $result = "$method=$r->{result}";
146  
147 $result .= ' ' . $self->createComment($r->{comment})
148 3 ▶ if defined $r->{comment};
Branch: 1 branch
BranchTrueFalseTotal
if defined $r->{"comment"} 1 2 3
149  
150 3 ▶ if(my $reason = $r->{reason})
Branch: 1 branch
BranchTrueFalseTotal
if (my $reason = $r->{"reason"}) 0 3 3
151 0 { $reason =~ s/"/\\"/g;
152 0 $result .= qq{ reason="$reason"};
153 }
154  
155 3 foreach my $prop (sort keys %$r)
156 12 ▶ { index($prop, '.') > -1 or next;
Branch: 1 branch
BranchTrueFalseTotal
index($prop, ".") != -1 or next 2 10 12
157 2 my $value = $r->{$prop};
158 2 $value =~ s/"/\\"/g;
159 2 $result .= qq{ $prop="$value"};
160 }
161  
162 3 push @results, $result;
163 }
164  
165 3 ▶ push @results, 'none' unless @results;
Branch: 1 branch
BranchTrueFalseTotal
unless @results 1 2 3
166 3 join '; ', $source, @results;
167 }
168  
169 #--------------------
170  
171 sub addAttribute($;@)
172 0 ▶{ my $self = shift;
Subroutine addAttribute: not called CC=1 SCAR=6.9
Pod documented
173 0 error __x"no attributes for Authentication-Results.";
174 0 $self;
175 }
176  
177  
178 11 ▶sub server() { $_[0]->{MMFA_server} }
Subroutine server: called CC=1 SCAR=0.0
Pod documented
179 10 ▶sub version() { $_[0]->{MMFA_version} }
Subroutine version: called CC=1 SCAR=0.0
Pod documented
180  
181  
182 10 ▶sub results() { @{ $_[0]->{MMFA_results}} }
Subroutine results: called CC=1 SCAR=0.0
Pod documented
183  
184  
185 sub addResult($)
186 11 ▶{ my $self = shift;
Subroutine addResult: called CC=5 SCAR=16.4
Pod documented
187  
188 11 ▶ my $r = @_==1 ? shift : {@_};
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 9 2 11
189 11 ▶ $r->{method} && $r->{result} or return ();
Branch: 1 branch
BranchTrueFalseTotal
$r->{"method"} and $r->{"result"} or return () 11 0 11
Condition33%1/3
$r->{"method"} and $r->{"result"}
!ll&&!rl&&r
0011
MC/DC0%0/2
$r->{"method"} and $r->{"result"}
$r->{"method"} $r->{"result"}
Truth table33%1/3
A and B
A= $r->{"method"}B= $r->{"result"}
ABresult
0X0
100
111
190 11 ▶ $r->{method_version} ||= 1;
Condition100%2/2
$r->{"method_version"} ||= 1
l!l
29
MC/DC100%1/1
$r->{"method_version"} ||= 1
$r->{"method_version"}
Truth table100%2/2
A
A= $r->{"method_version"}
Aresult
11
00
191 11 push @{$self->{MMFA_results}}, $r;
192 11 delete $self->{MMFF_body};
193  
194 11 $r;
195 }
196  
197 #--------------------
198  
199 28 1;
« Message.pm ↑ Summary Message/Head/Partial.pm »