| 1 | # Copyrights 1995-2024 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 the bundle MailTools. Meta-POD processed with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md for Copyright. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | package Mail::Address;{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | our $VERSION = '2.22'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # use locale; removed in version 1.78, because it causes taint problems | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub Version { our $VERSION } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # given a comment, attempt to extract a person's name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | sub _extract_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 49 | ▶ | { # This function can be called as method as well | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_name: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 49 | ▶ | my $self = @_ && ref $_[0] ? shift : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and ref $_[0]
MC/DC50%1/2
@_ and ref $_[0]
@_
ref $_[0]
Truth table66%2/3
A and B
A= @_B= ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 49 | ▶ | local $_ = shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | or return ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # Using encodings, too hard. See Mail::Message::Field::Full. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 38 | ▶ | return '' if m/\=\?.*?\?\=/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # trim whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 38 | s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 38 | s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 38 | s/\s+/ /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # Disregard numeric names (e.g. 123456.1234@compuserve.com) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 38 | ▶ | return "" if /^[\d ]+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 38 | s/^\((.*)\)$/$1/; # remove outermost parenthesis | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 38 | s/^"(.*)"$/$1/; # remove outer quotation marks | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 38 | s/\(.*?\)//g; # remove minimal embedded comments | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 38 | s/\\//g; # remove all escapes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 38 | s/^"(.*)"$/$1/; # remove internal quotation marks | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 38 | s/^([^\s]+) ?, ?(.*)$/$2 $1/; # reverse "Last, First M." if applicable | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 38 | s/,.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # Change casing only when the name contains only upper or only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # lower cased characters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 38 | ▶ | unless( m/[A-Z]/ && m/[a-z]/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
/[A-Z]/ and /[a-z]/
MC/DC100%2/2
/[A-Z]/ and /[a-z]/
/[A-Z]/
/[a-z]/
Truth table100%3/3
A and B
A= /[A-Z]/B= /[a-z]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | { # Set the case of the name to first char upper rest lower | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 9 | s/\b(\w+)/\L\u$1/igo; # Upcase first letter on name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 9 | s/\bMc(\w)/Mc\u$1/igo; # Scottish names such as 'McLeod' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 9 | s/\bo'(\w)/O'\u$1/igo; # Irish names such as 'O'Malley, O'Reilly' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 9 | s/\b(x*(ix)?v*(iv)?i*)\b/\U$1/igo; # Roman numerals, eg 'Level III Support' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # some cleanup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 38 | s/\[[^\]]*\]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 38 | s/(^[\s'"]+|[\s'"]+$)//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 38 | s/\s{2,}/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 38 | $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | sub _tokenise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 44 | ▶ | { local $_ = join ',', @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tokenise: called CC=12 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 44 | my (@words,$snippet,$field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 44 | s/\A\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 44 | s/[\r\n]+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 44 | ▶ | while ($_ ne '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 437 | { $field = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 437 | ▶ | if(s/^\s*\(/(/ ) # (...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 18 | { my $depth = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 18 | ▶ | PAREN: while(s/^(\(([^\(\)\\]|\\.)*)//) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 23 | { $field .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 23 | $depth++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 23 | ▶ | while(s/^(([^\(\)\\]|\\.)*\)\s*)//) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 23 | { $field .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 23 | ▶ | last PAREN unless --$depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | $field .= $1 if s/^(([^\(\)\\]|\\.)+)//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 18 | ▶ | carp "Unmatched () '$field' '$_'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | if $depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 18 | $field =~ s/\s+\Z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 18 | push @words, $field; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 18 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 419 | ▶ | if( s/^("(?:[^"\\]+|\\.)*")\s*// # "..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
s/^("(?:[^"\\]+|\\.)*")\s*// or s/^(\[(?:[^\]\\]+|\\.)*\])\s*// or s/^([^\s()<>\@,;:\\".[\]]+)\s*// or s/^([()<>\@,;:\\".[\]])\s*//
s/^("(?:[^"\\]+|\\.)*")\s*// or s/^(\[(?:[^\]\\]+|\\.)*\])\s*// or s/^([^\s()<>\@,;:\\".[\]]+)\s*//
s/^("(?:[^"\\]+|\\.)*")\s*// or s/^(\[(?:[^\]\\]+|\\.)*\])\s*//
MC/DC0%0/4
s/^("(?:[^"\\]+|\\.)*")\s*// or s/^(\[(?:[^\]\\]+|\\.)*\])\s*// or s/^([^\s()<>\@,;:\\".[\]]+)\s*// or s/^([()<>\@,;:\\".[\]])\s*//
s/^("(?:[^"\\]+|\\.)*")\s*//
s/^(\[(?:[^\]\\]+|\\.)*\])\s*//
s/^([^\s()<>\@,;:\\".[\]]+)\s*//
s/^([()<>\@,;:\\".[\]])\s*//
Truth table60%3/5
A or B or C or D
A= s/^("(?:[^"\\]+|\\.)*")\s*//B= s/^(\[(?:[^\]\\]+|\\.)*\])\s*//C= s/^([^\s()<>\@,;:\\".[\]]+)\s*//D= s/^([()<>\@,;:\\".[\]])\s*//
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | || s/^(\[(?:[^\]\\]+|\\.)*\])\s*// # [...] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | || s/^([^\s()<>\@,;:\\".[\]]+)\s*// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | || s/^([()<>\@,;:\\".[\]])\s*// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 419 | { push @words, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 419 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | croak "Unrecognised line: $_"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 44 | push @words, ","; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 44 | \@words; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | sub _find_next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 92 | ▶ | { my ($idx, $tokens, $len) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_next: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 92 | ▶ | while($idx < $len) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 304 | { my $c = $tokens->[$idx]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 304 | ▶ | return $c if $c eq ',' || $c eq ';' || $c eq '<'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$c eq "," or $c eq ";" or $c eq "<"
$c eq "," or $c eq ";"
MC/DC100%3/3
$c eq "," or $c eq ";" or $c eq "<"
$c eq ","
$c eq ";"
$c eq "<"
Truth table100%4/4
A or B or C
A= $c eq ","B= $c eq ";"C= $c eq "<"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 256 | $idx++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 44 | ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | sub _complete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 51 | ▶ | { my ($class, $phrase, $address, $comment) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_complete: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 51 | ▶ | @$phrase || @$comment || @$address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@$phrase or @$comment or @$address
@$phrase or @$comment
MC/DC0%0/3
@$phrase or @$comment or @$address
@$phrase
@$comment
@$address
Truth table75%3/4
A or B or C
A= @$phraseB= @$commentC= @$address
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 51 | my $o = $class->new(join(" ",@$phrase), join("",@$address), join(" ",@$comment)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 51 | @$phrase = @$address = @$comment = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 51 | $o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | #------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | sub new(@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 51 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 51 | bless [@_], $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | sub parse(@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 44 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=17 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 44 | my @line = grep {defined} @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 44 | my $line = join '', @line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 44 | my (@phrase, @comment, @address, @objs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 44 | my ($depth, $idx) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 44 | my $tokens = _tokenise @line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 44 | my $len = @$tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 44 | my $next = _find_next $idx, $tokens, $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 44 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 44 | ▶ | for(my $idx = 0; $idx < $len; $idx++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 481 | { $_ = $tokens->[$idx]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 481 | ▶ | if(substr($_,0,1) eq '(') { push @comment, $_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 20 | elsif($_ eq '<') { $depth++ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 20 | ▶ | elsif($_ eq '>') { $depth-- if $depth } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ▶ | elsif($_ eq ',' || $_ eq ';') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_ eq "," or $_ eq ";"
MC/DC100%2/2
$_ eq "," or $_ eq ";"
$_ eq ","
$_ eq ";"
Truth table100%3/3
A or B
A= $_ eq ","B= $_ eq ";"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 48 | ▶ | { warn "Unmatched '<>' in $line" if $depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 48 | my $o = $class->_complete(\@phrase, \@address, \@comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 48 | ▶ | push @objs, $o if defined $o; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 48 | $depth = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 48 | $next = _find_next $idx+1, $tokens, $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 137 | elsif($depth) { push @address, $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 32 | elsif($next eq '<') { push @phrase, $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | ▶ | elsif( /^[.\@:;]$/ || !@address || $address[-1] =~ /^[.\@:;]$/ ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
/^[.\@:;]$/ or not @address or $address[-1] =~ /^[.\@:;]$/
/^[.\@:;]$/ or not @address
MC/DC100%3/3
/^[.\@:;]$/ or not @address or $address[-1] =~ /^[.\@:;]$/
/^[.\@:;]$/
not @address
$address[-1] =~ /^[.\@:;]$/
Truth table100%4/4
A or not(B) or C
A= /^[.\@:;]$/B= not @addressC= $address[-1] =~ /^[.\@:;]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 203 | { push @address, $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | ▶ | { warn "Unmatched '<>' in $line" if $depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | my $o = $class->_complete(\@phrase, \@address, \@comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | ▶ | push @objs, $o if defined $o; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | $depth = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | push @address, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 44 | @objs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | #------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 44 | ▶ | sub phrase { shift->set_or_get(0, @_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
phrase: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 44 | ▶ | sub address { shift->set_or_get(1, @_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
address: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 26 | ▶ | sub comment { shift->set_or_get(2, @_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comment: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | sub set_or_get($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 114 | ▶ | { my ($self, $i) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_or_get: called CC=3 SCAR=17.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 114 | ▶ | @_ or return $self->[$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $val = $self->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $self->[$i] = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 3 | my $atext = '[\-\w !#$%&\'*+/=?^`{|}~]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | sub format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 44 | ▶ | { my @addrs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format: called CC=15 SCAR=29.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 44 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 44 | { my ($phrase, $email, $comment) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 44 | my @addr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 44 | ▶ | if(defined $phrase && length $phrase) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $phrase and length $phrase
MC/DC50%1/2
defined $phrase and length $phrase
defined $phrase
length $phrase
Truth table66%2/3
A and B
A= defined $phraseB= length $phrase
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 18 | ▶ | { push @addr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | , $phrase =~ /^(?:\s*$atext\s*)+$/o ? $phrase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | : $phrase =~ /(?<!\\)"/ ? $phrase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | : qq("$phrase"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 18 | ▶ | push @addr, "<$email>" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $email and length $email
MC/DC0%0/2
defined $email and length $email
defined $email
length $email
Truth table33%1/3
A and B
A= defined $emailB= length $email
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | if defined $email && length $email; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | ▶ | elsif(defined $email && length $email) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $email and length $email
MC/DC0%0/2
defined $email and length $email
defined $email
length $email
Truth table33%1/3
A and B
A= defined $emailB= length $email
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 26 | { push @addr, $email; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 44 | ▶ | if(defined $comment && $comment =~ /\S/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $comment and $comment =~ /\S/
MC/DC50%1/2
defined $comment and $comment =~ /\S/
defined $comment
$comment =~ /\S/
Truth table66%2/3
A and B
A= defined $commentB= $comment =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 16 | { $comment =~ s/^\s*\(?/(/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 16 | $comment =~ s/\)?\s*$/)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 44 | ▶ | push @addr, $comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $comment and length $comment
MC/DC50%1/2
defined $comment and length $comment
defined $comment
length $comment
Truth table66%2/3
A and B
A= defined $commentB= length $comment
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | if defined $comment && length $comment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 44 | ▶ | push @addrs, join(" ", @addr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | if @addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 44 | join ", ", @addrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | #------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | sub name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 44 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 44 | my $phrase = $self->phrase; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 44 | my $addr = $self->address; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 44 | ▶ | $phrase = $self->comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $phrase and length $phrase
MC/DC50%1/2
defined $phrase and length $phrase
defined $phrase
length $phrase
Truth table66%2/3
A and B
A= defined $phraseB= length $phrase
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | unless defined $phrase && length $phrase; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 44 | my $name = $self->_extract_name($phrase); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # first.last@domain address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 44 | ▶ | if($name eq '' && $addr =~ /([^\%\.\@_]+([\._][^\%\.\@_]+)+)[\@\%]/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name eq "" and $addr =~ /([^\%\.\@_]+([\._][^\%\.\@_]+)+)[\@\%]/
MC/DC100%2/2
$name eq "" and $addr =~ /([^\%\.\@_]+([\._][^\%\.\@_]+)+)[\@\%]/
$name eq ""
$addr =~ /([^\%\.\@_]+([\._][^\%\.\@_]+)+)[\@\%]/
Truth table100%3/3
A and B
A= $name eq ""B= $addr =~ /([^\%\.\@_]+([\._][^\%\.\@_]+)+)[\@\%]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 4 | { ($name = $1) =~ s/[\._]+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | $name = _extract_name $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 44 | ▶ | if($name eq '' && $addr =~ m#/g=#i) # X400 style address | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name eq "" and $addr =~ m[/g=]i
MC/DC100%2/2
$name eq "" and $addr =~ m[/g=]i
$name eq ""
$addr =~ m[/g=]i
Truth table100%3/3
A and B
A= $name eq ""B= $addr =~ m[/g=]i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | { my ($f) = $addr =~ m#g=([^/]*)#i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | my ($l) = $addr =~ m#s=([^/]*)#i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | $name = _extract_name "$f $l"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 44 | ▶ | length $name ? $name : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | sub host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | { my $addr = shift->address || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host: not called CC=3 SCAR=24.8
Pod
documented
Condition0%0/2
(shift())->address || ''
MC/DC0%0/1
(shift())->address || ''
(shift())->address
Truth table0%0/2
A
A= (shift())->address
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $i = rindex $addr, '@'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | $i >= 0 ? substr($addr, $i+1) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | sub user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | { my $addr = shift->address || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user: not called CC=3 SCAR=24.8
Pod
documented
Condition0%0/2
(shift())->address || ''
MC/DC0%0/1
(shift())->address || ''
(shift())->address
Truth table0%0/2
A
A= (shift())->address
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $i = rindex $addr, '@'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | $i >= 0 ? substr($addr,0,$i) : $addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||