Message/Field/AuthResults.pm

filter: Statementstmt 94.7% 109 / 115 Branchbran 73.3% 44 / 60 Conditioncond 41.1% 7 / 17 MC/DCmcdc 11.1% 1 / 9 Subroutinesub 92.3% 12 / 13 Podpod 87.5% 7 / 8 totaltotal 81.0% 180 / 222 SCAR 38.9
CC
41
Cov
83%
parse
32.2
produceBody
9.1
addResult
5.1
CRAP 48.8
« Message/Field/Addresses.pm ↑ Summary Message/Body/Construct.pm »
1 # Copyrights 2001-2023 by [Mark Overmeer <markov@cpan.org>].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.03.
5 # This code is part of distribution Mail-Message. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package Mail::Message::Field::AuthResults;
10 24 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 24 $VERSION = '3.013';
12  
13 24 ▶use base 'Mail::Message::Field::Structured';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 24 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21  
22 sub init($)
23 9 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=3 SCAR=11.0
Pod undocumented
24 9 $self->{MMFA_server} = delete $args->{server};
25 9 $self->{MMFA_version} = delete $args->{version};
26  
27 9 $self->{MMFA_results} = [];
28 9 ▶ $self->addResult($_) for @{delete $args->{results} || []};
Branch: 1 branch
BranchTrueFalseTotal
delete $args->{"results"} or [] 9 0 9
29  
30 9 $self->SUPER::init($args);
31 }
32  
33 sub parse($)
34 8 ▶{ my ($self, $string) = @_;
Subroutine parse: called CC=27 SCAR=34.7
Pod documented
35 8 $string =~ s/\r?\n/ /g;
36  
37 8 (undef, $string) = $self->consumeComment($string);
38 8 ▶ $self->{MMFA_server} = $string =~ s/^\s*([.\w-]*\w)// ? $1 : 'unknown';
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([.\w-]*\w)// ? : 7 1 8
39  
40 8 (undef, $string) = $self->consumeComment($string);
41 8 ▶ $self->{MMFA_version} = $string =~ s/^\s*([0-9]+)// ? $1 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([0-9]+)// ? : 3 5 8
42  
43 8 (undef, $string) = $self->consumeComment($string);
44 8 $string =~ s/^.*?\;/;/; # remove accidents
45  
46 8 my @results;
47 8 ▶ while( $string =~ s/^\s*\;// )
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*\;//) 12 8 20
48 {
49 12 (undef, $string) = $self->consumeComment($string);
50 12 ▶ if($string =~ s/^\s*none//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*none//) 3 9 12
51 3 { (undef, $string) = $self->consumeComment($string);
52 3 next;
53 }
54  
55 9 my %result;
56 9 push @results, \%result;
57  
58 9 ▶ $string =~ s/^\s*([\w-]*\w)// or next;
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([\w-]*\w)// or next 0 9 9
59 9 $result{method} = $1;
60  
61 9 (undef, $string) = $self->consumeComment($string);
62 9 ▶ if($string =~ s!^\s*/!!)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s[^\s*/][]) 1 8 9
63 1 { (undef, $string) = $self->consumeComment($string);
64 1 ▶ $result{method_version} = $1 if $string =~ s/^\s*([0-9]+)//;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ s/^\s*([0-9]+)// 1 0 1
65 }
66  
67 9 (undef, $string) = $self->consumeComment($string);
68 9 ▶ if($string =~ s/^\s*\=//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*\=//) 9 0 9
69 9 { (undef, $string) = $self->consumeComment($string);
70 9 ▶ $result{result} = $1
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ s/^\s*(\w+)// 9 0 9
71 if $string =~ s/^\s*(\w+)//;
72 }
73  
74 9 (my $comment, $string) = $self->consumeComment($string);
75 9 ▶ if($comment)
Branch: 1 branch
BranchTrueFalseTotal
if ($comment) 3 6 9
76 3 { $result{comment} = $comment;
77 3 (undef, $string) = $self->consumeComment($string);
78 }
79  
80 9 ▶ if($string =~ s/\s*reason//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\s*reason//) 2 7 9
81 2 { (undef, $string) = $self->consumeComment($string);
82 2 ▶ if($string =~ s/\s*\=//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/\s*\=//) 2 0 2
83 2 { (undef, $string) = $self->consumeComment($string);
84 2 ▶ $result{reason} = $1
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'// or $string =~ s/^(\w+)// 0 0 0
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
85 if $string =~ s/^\"([^"]*)\"//
86 || $string =~ s/^\'([^']*)\'//
87 || $string =~ s/^(\w+)//;
88 }
89 }
90  
91 9 ▶ while($string =~ /\S/)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\S/) 13 4 17
92 13 { (undef, $string) = $self->consumeComment($string);
93 13 ▶ last if $string =~ /^\s*\;/;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /^\s*\;/ 4 9 13
94  
95 9 ▶ my $ptype = $string =~ s/^\s*([\w-]+)// ? $1 : last;
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([\w-]+)// ? : 8 1 9
96 8 (undef, $string) = $self->consumeComment($string);
97  
98 8 my ($property, $value);
99 8 ▶ if($string =~ s/^\s*\.//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*\.//) 8 0 8
100 8 { (undef, $string) = $self->consumeComment($string);
101 8 ▶ $property = $string =~ s/^\s*([\w-]+)// ? $1 : last;
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\s*([\w-]+)// ? : 8 0 8
102 8 (undef, $string) = $self->consumeComment($string);
103 8 ▶ if($string =~ s/^\s*\=//)
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ s/^\s*\=//) 8 0 8
104 8 { (undef, $string) = $self->consumeComment($string);
105 8 $string =~ s/^\s+//;
106 8 ▶ $string =~ s/^\"([^"]*)\"//
Branch: 1 branch
BranchTrueFalseTotal
$string =~ s/^\"([^"]*)\"// or $string =~ s/^\'([^']*)\'// or $string =~ s/^([\w\@.-]+)// or last 0 8 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
107 || $string =~ s/^\'([^']*)\'//
108 || $string =~ s/^([\w@.-]+)//
109 or last;
110  
111 8 $value = $1;
112 }
113 }
114  
115 8 ▶ if(defined $value)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 8 0 8
116 8 { $result{"$ptype.$property"} = $value;
117 }
118 else
119 0 { $string =~ s/^.*?\;/;/g; # recover from parser problem
120 }
121 }
122 }
123 8 $self->addResult($_) for @results;
124  
125 8 $self;
126 }
127  
128 sub produceBody()
129 3 ▶{ my $self = shift;
Subroutine produceBody: called CC=9 SCAR=22.1
Pod documented
130 3 my $source = $self->server;
131 3 my $version = $self->version;
132 3 ▶ $source .= " $version" if $version!=1;
Branch: 1 branch
BranchTrueFalseTotal
if $version != 1 0 3 3
133  
134 3 my @results;
135 3 foreach my $r ($self->results)
136 3 { my $method = $r->{method};
137 $method .= "/$r->{method_version}"
138 3 ▶ if $r->{method_version} != 1;
Branch: 1 branch
BranchTrueFalseTotal
if $r->{"method_version"} != 1 1 2 3
139  
140 3 my $result = "$method=$r->{result}";
141  
142 $result .= ' ' . $self->createComment($r->{comment})
143 3 ▶ if defined $r->{comment};
Branch: 1 branch
BranchTrueFalseTotal
if defined $r->{"comment"} 1 2 3
144  
145 3 ▶ if(my $reason = $r->{reason})
Branch: 1 branch
BranchTrueFalseTotal
if (my $reason = $r->{"reason"}) 0 3 3
146 0 { $reason =~ s/"/\\"/g;
147 0 $result .= qq{ reason="$reason"};
148 }
149  
150 3 foreach my $prop (sort keys %$r)
151 12 ▶ { index($prop, '.') > -1 or next;
Branch: 1 branch
BranchTrueFalseTotal
index($prop, ".") != -1 or next 10 2 12
152 2 my $value = $r->{$prop};
153 2 $value =~ s/"/\\"/g;
154 2 $result .= qq{ $prop="$value"};
155 }
156  
157 3 push @results, $result;
158 }
159  
160 3 ▶ push @results, 'none' unless @results;
Branch: 1 branch
BranchTrueFalseTotal
unless @results 1 2 3
161 3 join '; ', $source, @results;
162 }
163  
164 #------------------------------------------
165  
166  
167  
168 sub addAttribute($;@)
169 0 ▶{ my $self = shift;
Subroutine addAttribute: not called CC=1 SCAR=6.9
Pod documented
170 0 $self->log(ERROR => 'No attributes for Authentication-Results.');
171 0 $self;
172 }
173  
174  
175  
176 11 ▶sub server() { shift->{MMFA_server} }
Subroutine server: called CC=1 SCAR=0.0
Pod documented
177 10 ▶sub version() { shift->{MMFA_version} }
Subroutine version: called CC=1 SCAR=0.0
Pod documented
178  
179  
180 10 ▶sub results() { @{shift->{MMFA_results}} }
Subroutine results: called CC=1 SCAR=0.0
Pod documented
181  
182  
183 sub addResult($)
184 11 ▶{ my $self = shift;
Subroutine addResult: called CC=5 SCAR=16.4
Pod documented
185  
186 11 ▶ my $r = @_==1 ? shift : {@_};
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 9 2 11
187 11 ▶ $r->{method} && $r->{result} or return ();
Branch: 1 branch
BranchTrueFalseTotal
$r->{"method"} and $r->{"result"} or return () 0 11 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
188 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
189 11 push @{$self->{MMFA_results}}, $r;
190 11 delete $self->{MMFF_body};
191  
192 11 $r;
193 }
194  
195 #------------------------------------------
196  
197  
198 24 1;
« Message/Field/Addresses.pm ↑ Summary Message/Body/Construct.pm »