| 1 | package Email::MIME::RFC2047::Address; | ||||||||||||||||||||||||||||
| 2 | 4 | $Email::MIME::RFC2047::Address::VERSION = '0.96'; | |||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Handling of MIME encoded addresses | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use base qw(Email::MIME::RFC2047::Parser); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Email::MIME::RFC2047::Decoder; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Email::MIME::RFC2047::Group; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Email::MIME::RFC2047::Mailbox; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Email::MIME::RFC2047::MailboxList; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | my $domain_part_re = qr/[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?/; | |||||||||||||||||||||||||||
| 16 | 4 | my $addr_spec_re = qr{ | |||||||||||||||||||||||||||
| 17 | [\w&'*+.\/=?^{}~-]+ | ||||||||||||||||||||||||||||
| 18 | \@ | ||||||||||||||||||||||||||||
| 19 | $domain_part_re (?: \. $domain_part_re)+ | ||||||||||||||||||||||||||||
| 20 | }x; | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub parse { | ||||||||||||||||||||||||||||
| 23 | 36 | ▶ | my ($class, $string, $decoder) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=12 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 36 | ▶ | my $string_ref = ref($string) ? $string : \$string; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 36 | my $address; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 36 | ▶ | if ($$string_ref =~ /\G\s*($addr_spec_re)\s*/cg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 9 | $address = Email::MIME::RFC2047::Mailbox->new($1); | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||
| 32 | 27 | ▶ | $decoder ||= Email::MIME::RFC2047::Decoder->new(); | ||||||||||||||||||||||||||
|
Condition66%2/3
$decoder ||= "Email::MIME::RFC2047::Decoder"->new
MC/DC0%0/2
$decoder ||= "Email::MIME::RFC2047::Decoder"->new
$decoder
"Email::MIME::RFC2047::Decoder"->new
Truth table66%2/3
A ||= B
A= $decoderB= "Email::MIME::RFC2047::Decoder"->new
| |||||||||||||||||||||||||||||
| 33 | 27 | my $name = $decoder->decode_phrase($string_ref); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 27 | ▶ | if ($$string_ref =~ /\G<\s*($addr_spec_re)\s*>\s*/cg) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 36 | 17 | my $addr_spec = $1; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 17 | $address = Email::MIME::RFC2047::Mailbox->new( | |||||||||||||||||||||||||||
| 39 | address => $addr_spec, | ||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 17 | ▶ | $address->name($name) if $name ne ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | elsif ($$string_ref =~ /\G:/cg) { | ||||||||||||||||||||||||||||
| 45 | 8 | ▶ | return $class->_parse_error($string_ref, 'group name') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | if $name eq ''; | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 8 | my $mailbox_list; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 8 | ▶ | if ($$string_ref =~ /\G\s*;\s*/cg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 2 | $mailbox_list = Email::MIME::RFC2047::MailboxList->new(); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||||||||||
| 54 | 6 | $mailbox_list = Email::MIME::RFC2047::MailboxList->parse( | |||||||||||||||||||||||||||
| 55 | $string_ref, $decoder | ||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 4 | ▶ | $$string_ref =~ /\G;\s*/cg | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | or return $class->_parse_error($string_ref, 'group'); | ||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 6 | $address = Email::MIME::RFC2047::Group->new( | |||||||||||||||||||||||||||
| 63 | name => $name, | ||||||||||||||||||||||||||||
| 64 | mailbox_list => $mailbox_list, | ||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | else { | ||||||||||||||||||||||||||||
| 68 | 2 | return $class->_parse_error($string_ref, 'address'); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 32 | ▶ | if (!ref($string) && pos($string) < length($string)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $string and pos $string < length $string
MC/DC0%0/2
not ref $string and pos $string < length $string
not ref $string
pos $string < length $string
Truth table66%2/3
not(A) and B
A= not ref $stringB= pos $string < length $string
| |||||||||||||||||||||||||||||
| 73 | 0 | return $class->_parse_error($string_ref); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 32 | return $address; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 4 | 1; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||||||||||