| 1 | # This code is part of Perl distribution HTML-FromMail version 4.00. | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # The POD got stripped from this file by OODoc version 3.05. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # For contributors see file ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2003-2025 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 HTML::FromMail::Field;{ | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '4.00'; | |||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use base 'HTML::FromMail::Page'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Log::Report 'html-frommail'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Mail::Message::Field::Full (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | sub init($) | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | $args->{topic} ||= 'field'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"topic"} ||= "field"
MC/DC0%0/1
$args->{"topic"} ||= "field"
$args->{"topic"}
Truth table0%0/2
A
A= $args->{"topic"}
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $self->SUPER::init($args); | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | #----------- | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | #----------- | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | sub fromHead($$@) | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | { my ($self, $head, $name, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fromHead: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $head->study($name); | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | sub htmlName($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | { my ($self, $field, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
htmlName: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | defined $field or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $reform = $args->{capitals} || $self->settings->{names} || 'UNCHANGED'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$args->{'capitals'} || $self->settings->{'names'} || 'UNCHANGED'
$args->{"capitals"} or $self->settings->{"names"}
MC/DC0%0/2
$args->{'capitals'} || $self->settings->{'names'} || 'UNCHANGED'
$args->{"capitals"}
$self->settings->{"names"}
Truth table0%0/3
A or B
A= $args->{"capitals"}B= $self->settings->{"names"}
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $self->plain2html($reform ? $field->wellformedName : $field->Name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | sub htmlBody($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | { my ($self, $field, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
htmlBody: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $settings = $self->settings; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my $wrap = $args->{wrap} || $settings->{wrap}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args->{'wrap'} || $settings->{'wrap'}
MC/DC0%0/2
$args->{'wrap'} || $settings->{'wrap'}
$args->{'wrap'}
$settings->{'wrap'}
Truth table0%0/3
A || B
A= $args->{'wrap'}B= $settings->{'wrap'}
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my $content = $args->{content} || $settings->{content} || (defined $wrap && 'REFOLD') || 'DECODED'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/10
$args->{'content'} || $settings->{'content'} || defined $wrap && 'REFOLD' || 'DECODED'
$args->{"content"} or $settings->{"content"} or defined $wrap and "REFOLD"
$args->{"content"} or $settings->{"content"}
defined $wrap and "REFOLD"
MC/DC0%0/3
$args->{'content'} || $settings->{'content'} || defined $wrap && 'REFOLD' || 'DECODED'
$args->{"content"}
$settings->{"content"}
defined $wrap
Truth table0%0/4
A or B or C
A= $args->{"content"}B= $settings->{"content"}C= defined $wrap
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if($field->isa('Mail::Message::Field::Addresses')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | { my $how = $args->{address} || $settings->{address} || 'MAILTO'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$args->{'address'} || $settings->{'address'} || 'MAILTO'
$args->{"address"} or $settings->{"address"}
MC/DC0%0/2
$args->{'address'} || $settings->{'address'} || 'MAILTO'
$args->{"address"}
$settings->{"address"}
Truth table0%0/3
A or B
A= $args->{"address"}B= $settings->{"address"}
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $how eq 'PLAIN' or return $self->addressField($field, $how, $args) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | return $self->plain2html($field->unfoldedBody) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | if $content eq 'UNFOLDED'; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $field->setWrapLength($wrap || 78) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$wrap || 78
MC/DC0%0/1
$wrap || 78
$wrap
Truth table0%0/2
A
A= $wrap
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | if $content eq 'REFOLD'; | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->plain2html($field->foldedBody); | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | sub addressField($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | { my ($self, $field, $how, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addressField: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | return $self->plain2html($field->foldedBody) if $how eq 'PLAIN'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | return join ",<br />", map $_->address, $field->addresses | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | if $how eq 'ADDRESS'; | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | return join ",<br />", map {$_->phrase || $_->address} $field->addresses | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_->phrase || $_->address
MC/DC0%0/2
$_->phrase || $_->address
$_->phrase
$_->address
Truth table0%0/3
A || B
A= $_->phraseB= $_->address
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | if $how eq 'PHRASE'; | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if($how eq 'MAILTO') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | { my @links; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | foreach my $address ($field->addresses) | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | { my $addr = $address->address; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | my $phrase = $address->phrase || $addr; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$address->phrase || $addr
MC/DC0%0/2
$address->phrase || $addr
$address->phrase
$addr
Truth table0%0/3
A || B
A= $address->phraseB= $addr
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | push @links, qq[<a href="mailto:$addr">$phrase</a>]; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return join ",<br />", @links; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if($how eq 'LINK') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | { my @links; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | foreach my $address ($field->addresses) | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | { my $addr = $address->address; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $phrase = $address->phrase || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$address->phrase || ''
MC/DC0%0/1
$address->phrase || ''
$address->phrase
Truth table0%0/2
A
A= $address->phrase
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | push @links, qq[$phrase <<a href="mailto:$addr">$addr</a>>]; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return join ",<br />", @links; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | error __x"don't know address field formatting '{how}'.", how => $how; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | sub htmlAddresses($$) | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | { my ($self, $field, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
htmlAddresses: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $field->can('addresses') or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my @addrs; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | foreach my $address ($field->addresses) | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | { my %addr = ( | |||||||||||||||||||||||||||||||||||||||||
| 115 | email => $address->address, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | address => $self->plain2html($address->string), | ||||||||||||||||||||||||||||||||||||||||||
| 117 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if(defined(my $phrase = $address->phrase)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | { $addr{phrase} = $self->plain2html($phrase); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | push @addrs, \%addr; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | \@addrs; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||