| 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::URIs;{ | ||||||||||||||||||||||||||||||||
| 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 | 28 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | #-------------------- | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | #-------------------- | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | sub init($) | ||||||||||||||||||||||||||||||||
| 31 | 7 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=9 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 7 | my ($body, @body); | |||||||||||||||||||||||||||||||
| 34 | 7 | ▶ | if($body = delete $args->{body}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 35 | 7 | ▶ | { @body = ref $body eq 'ARRAY' ? @$body : ($body); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 36 | 7 | ▶ | @body or return (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 7 | $self->{MMFU_uris} = []; | |||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 7 | ▶ | if(@body > 1 || blessed $body[0]) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
@body > 1 or builtin::blessed($body[0])
MC/DC50%1/2
@body > 1 or builtin::blessed($body[0])
@body > 1
builtin::blessed($body[0])
Truth table66%2/3
A or B
A= @body > 1B= builtin::blessed($body[0])
| |||||||||||||||||||||||||||||||||
| 42 | 2 | { $self->addURI($_) for @body; | |||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||
| 44 | elsif(defined $body) | ||||||||||||||||||||||||||||||||
| 45 | 5 | ▶ | { $body = "<$body>\n" unless index($body, '<') >= 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | 5 | $args->{body} = $body; | |||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 7 | $self->SUPER::init($args); | |||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | sub parse($) | ||||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | { my ($self, $string) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 54 | 5 | my @raw = $string =~ m/\<([^>]+)\>/g; # simply ignore all but <> | |||||||||||||||||||||||||||||||
| 55 | 5 | $self->addURI($_) for @raw; | |||||||||||||||||||||||||||||||
| 56 | 5 | $self; | |||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | sub produceBody() | ||||||||||||||||||||||||||||||||
| 60 | 3 | ▶ | { my @uris = sort map $_->as_string, $_[0]->URIs; | ||||||||||||||||||||||||||||||
|
Subroutine
produceBody: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 61 | 3 | local $" = '>, <'; | |||||||||||||||||||||||||||||||
| 62 | 3 | ▶ | @uris ? "<@uris>" : undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | #-------------------- | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | sub addURI(@) | ||||||||||||||||||||||||||||||||
| 68 | 9 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
addURI: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 69 | 9 | ▶ | my $uri = blessed $_[0] ? shift : URI->new(@_); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | 9 | ▶ | push @{$self->{MMFU_uris}}, $uri->canonical if defined $uri; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 71 | 9 | delete $self->{MMFF_body}; | |||||||||||||||||||||||||||||||
| 72 | 9 | $uri; | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 10 | ▶ | sub URIs() { @{ $_[0]->{MMFU_uris}} } | ||||||||||||||||||||||||||||||
|
Subroutine
URIs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | sub addAttribute($;@) | ||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
addAttribute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 81 | 0 | error __x"no attributes for URI fields."; | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | #-------------------- | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | 28 | 1; | |||||||||||||||||||||||||||||||