| 1 | package AnyEvent::MCP::Worker::IMAP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use common::sense; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Mail::IMAPTalk (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use IO::Socket::SSL (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use MIME::Base64 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use MIME::QuotedPrint (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Encode::MIME::Header (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Extra charsets register with Encode only when their modules are loaded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # They're optional: missing modules must not prevent IMAP from starting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | eval { require Encode::HanExtra }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | eval { require Encode::JIS2K }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | eval { require Encode::EUCJPASCII }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use JSON::XS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use AnyEvent::MCP (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # mboxo stores raw messages without reliably escaping From_ lines. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # check the original bytes, not decoded MIME parts; never rewrite the message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub mbox_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mbox_from: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my ($bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $bytes =~ /^From[ \t]+\S+[ \t]+[^\r\n]* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | (?: [0-9]{2} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | | \b(?i:Mon|Tue|Wed|Thu|Fri|Sat|Sun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\b | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | )/mx or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | 1 + ((substr $bytes, 0, $-[0]) =~ tr/\n//) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | my ($imap, $config, $sort_snapshot); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | sub imap_connect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
imap_connect: called CC=21 SCAR=48.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | my ($settings) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | $config = $settings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | undef $imap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | $config->{tls} =~ /\A(?:connect|starttls|none)\z/ or die "Invalid IMAP TLS mode\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | my %tls = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_PEER (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | SSL_verifycn_name => $config->{server}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | SSL_verifycn_scheme => "http", # DNS names and IP addresses, not a web protocol | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | if ($config->{tls} eq "connect") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $imap = Mail::IMAPTalk->new ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Server => $config->{server}, Port => $config->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | UseSSL => 1, UseBlocking => 1, PreserveINBOX => 1, %tls, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $imap = Mail::IMAPTalk->new ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | Server => $config->{server}, Port => $config->{port}, PreserveINBOX => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $imap or die "IMAP connection failed: $@\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ($config->{tls} eq "starttls") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | $imap->_imap_cmd ("starttls", 0, "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | or die "IMAP STARTTLS rejected: " . $imap->get_last_error . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | IO::Socket::SSL->start_SSL ($imap->{Socket}, %tls) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | or die "IMAP TLS handshake failed: " . IO::Socket::SSL::errstr () . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | delete $imap->{Cache}{capability}; # TLS changes advertised mechanisms | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $imap->{UseBlocking} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | ▶ | $imap or die "IMAP connection failed: $@\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | if (($config->{method} || "password") eq "oauth2") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$config->{'method'} || 'password'
MC/DC0%0/1
$config->{'method'} || 'password'
$config->{'method'}
Truth table50%1/2
A
A= $config->{'method'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | require AnyEvent::MCP::IMAP::OAuth2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | require Authen::SASL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | my $mechanism = uc ($config->{oauth}{"oauth-sasl"} || "xoauth2"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{'oauth'}{'oauth-sasl'} || 'xoauth2'
MC/DC0%0/1
$config->{'oauth'}{'oauth-sasl'} || 'xoauth2'
$config->{'oauth'}{'oauth-sasl'}
Truth table50%1/2
A
A= $config->{'oauth'}{'oauth-sasl'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | $imap->capability->{"auth=" . lc $mechanism} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | or die "IMAP server does not advertise AUTH=$mechanism\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | my $token = $config->{access_token} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | || AnyEvent::MCP::IMAP::OAuth2::refresh ($config->{account_file}, $config->{oauth}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$config->{'access_token'} || AnyEvent::MCP::IMAP::OAuth2::refresh($config->{'account_file'}, $config->{'oauth'})
MC/DC0%0/2
$config->{'access_token'} || AnyEvent::MCP::IMAP::OAuth2::refresh($config->{'account_file'}, $config->{'oauth'})
$config->{'access_token'}
AnyEvent::MCP::IMAP::OAuth2::refresh($config->{'account_file'}, $config->{'oauth'})
Truth table66%2/3
A || B
A= $config->{'access_token'}B= AnyEvent::MCP::IMAP::OAuth2::refresh($config->{'account_file'}, $config->{'oauth'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | my $sasl = Authen::SASL->new ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | mechanism => $mechanism, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | callback => { user => $config->{user}, pass => $token }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | $imap->authenticate ($sasl) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | or die "IMAP OAuth authentication failed: " . $imap->get_last_error . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $caps = $imap->capability; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $sasl = grep /^auth=(?:plain|login|digest-md5)\z/, keys %$caps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if (!$sasl && $caps->{logindisabled}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $sasl and $caps->{"logindisabled"}
MC/DC0%0/2
not $sasl and $caps->{"logindisabled"}
not $sasl
$caps->{"logindisabled"}
Truth table0%0/3
not(A) and B
A= not $saslB= $caps->{"logindisabled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | die "IMAP server advertises LOGINDISABLED and no supported AUTH mechanism. " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | . "Use tls connect/starttls, or allow cleartext authentication on the IMAP server.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if (!$sasl && $config->{password} =~ /[^\x00-\x7f]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $sasl and $config->{"password"} =~ /[^\x00-\x7f]/u
MC/DC0%0/2
not $sasl and $config->{"password"} =~ /[^\x00-\x7f]/u
not $sasl
$config->{"password"} =~ /[^\x00-\x7f]/u
Truth table0%0/3
not(A) and B
A= not $saslB= $config->{"password"} =~ /[^\x00-\x7f]/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | die "IMAP server offers no supported AUTH mechanism for a non-ASCII password.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | $imap->login ($config->{user}, $config->{password}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | or die "IMAP authentication failed: " . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$imap->get_last_error || $@ || 'server supplied no error details'
$imap->get_last_error or $@
MC/DC0%0/2
$imap->get_last_error || $@ || 'server supplied no error details'
$imap->get_last_error
$@
Truth table0%0/3
A or B
A= $imap->get_last_errorB= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ($imap->get_last_error || $@ || "server supplied no error details") . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | $imap->uid (1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | $imap->parse_mode (DecodeUTF8 => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | +{ connected => JSON::XS::true, capabilities => [sort keys %{$imap->capability}] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub checked ($$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checked: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my ($result, $what) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | defined $result && $result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
defined $result and $result
$imap->get_last_error || $@ || 'IMAP command failed'
$imap->get_last_error or $@
MC/DC0%0/2
defined $result and $result
defined $result
$result
MC/DC0%0/2
$imap->get_last_error || $@ || 'IMAP command failed'
$imap->get_last_error
$@
Truth table0%0/3
A and B
A= defined $resultB= $result
Truth table0%0/3
A or B
A= $imap->get_last_errorB= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | or die "$what: " . ($imap->get_last_error || $@ || "IMAP command failed") . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $result | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub mailbox { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mailbox: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my ($name, $writable) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | checked ($imap->select ($name, ReadOnly => !$writable), "Select $name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $validity = $imap->get_response_code ("uidvalidity"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | defined $validity or die "UIDVALIDITY not supplied for $name\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $validity | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub same_validity { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
same_validity: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my ($args, $writable) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $validity = mailbox ($args->{mailbox}, $writable); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | defined $args->{uidvalidity} && "$args->{uidvalidity}" eq "$validity" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args->{"uidvalidity"} and qq[$args->{"uidvalidity"}] eq "$validity"
MC/DC0%0/2
defined $args->{"uidvalidity"} and qq[$args->{"uidvalidity"}] eq "$validity"
defined $args->{"uidvalidity"}
qq[$args->{"uidvalidity"}] eq "$validity"
Truth table0%0/3
A and B
A= defined $args->{"uidvalidity"}B= qq[$args->{"uidvalidity"}] eq "$validity"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | or die "UIDVALIDITY mismatch (current $validity); refresh message references\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $validity | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub uids { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uids: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | ref $args->{uids} eq "ARRAY" && @{$args->{uids}} && @{$args->{uids}} <= 1000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $args->{"uids"} eq "ARRAY" and @{$args->{"uids"};} and @{$args->{"uids"};} <= 1000
ref $args->{"uids"} eq "ARRAY" and @{$args->{"uids"};}
MC/DC0%0/3
ref $args->{"uids"} eq "ARRAY" and @{$args->{"uids"};} and @{$args->{"uids"};} <= 1000
ref $args->{"uids"} eq "ARRAY"
@{$args->{"uids"};}
@{$args->{"uids"};} <= 1000
Truth table0%0/4
A and B and C
A= ref $args->{"uids"} eq "ARRAY"B= @{$args->{"uids"};}C= @{$args->{"uids"};} <= 1000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | or die "uids must contain 1..1000 message UIDs\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | for (@{$args->{uids}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | defined $_ && !ref $_ && /\A[1-9][0-9]*\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $_ and not ref $_ and /\A[1-9][0-9]*\z/u
defined $_ and not ref $_
MC/DC0%0/3
defined $_ and not ref $_ and /\A[1-9][0-9]*\z/u
defined $_
not ref $_
/\A[1-9][0-9]*\z/u
Truth table0%0/4
A and not(B) and C
A= defined $_B= not ref $_C= /\A[1-9][0-9]*\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | or die "Invalid UID\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | join ",", @{$args->{uids}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
message: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $validity = same_validity ($args, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $uid = $args->{uid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | my $f = checked ($imap->fetch ($uid, "(envelope flags internaldate rfc822.size bodystructure)"), "Fetch $uid")->{$uid} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | or die "Message $uid vanished\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | for my $key (qw(Subject From To Cc Bcc Reply-To Sender)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | $f->{envelope}{$key} = mime_header ($f->{envelope}{$key}) if exists $f->{envelope}{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | +{ uid => 0 + $uid, uidvalidity => $validity, %$f } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub mime_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mime_header: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | return $value unless defined $value && $value =~ /=\?[^?]+\?[bq]\?/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $value =~ /=\?[^?]+\?[bq]\?/iu
MC/DC0%0/2
defined $value and $value =~ /=\?[^?]+\?[bq]\?/iu
defined $value
$value =~ /=\?[^?]+\?[bq]\?/iu
Truth table0%0/3
A and B
A= defined $valueB= $value =~ /=\?[^?]+\?[bq]\?/iu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | (eval { Encode::decode ("MIME-Header", $value) }) // $value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
&Encode::decode("MIME-Header", $value)
}
} // $value
MC/DC0%0/2
eval {
do {
&Encode::decode("MIME-Header", $value)
}
} // $value
eval {
do {
&Encode::decode("MIME-Header", $value)
}
}
$value
Truth table0%0/3
A // B
A= eval {
do {
&Encode::decode("MIME-Header", $value)
}
}B= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub search_filter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_filter: not called CC=44 SCAR=75.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my ($filter, $depth, $nodes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | ref $filter eq "HASH" && (!$depth || keys %$filter) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $filter eq "HASH" and !$depth || keys %$filter
not $depth or keys %$filter
MC/DC0%0/3
ref $filter eq "HASH" and !$depth || keys %$filter
ref $filter eq "HASH"
not $depth
keys %$filter
Truth table0%0/4
A and not(B) or C
A= ref $filter eq "HASH"B= not $depthC= keys %$filter
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | or die "Invalid SEARCH filter group\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | ++$$nodes <= 100 && $depth <= 12 or die "SEARCH filter too complex\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
++$$nodes <= 100 and $depth <= 12
MC/DC0%0/2
++$$nodes <= 100 and $depth <= 12
++$$nodes <= 100
$depth <= 12
Truth table0%0/3
A and B
A= ++$$nodes <= 100B= $depth <= 12
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my @criteria; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | for my $key (sort keys %$filter) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $value = $filter->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if ($key eq "all" || $key eq "any") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition0%0/3
$key eq "all" or $key eq "any"
MC/DC0%0/2
$key eq "all" or $key eq "any"
$key eq "all"
$key eq "any"
Truth table0%0/3
A or B
A= $key eq "all"B= $key eq "any"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | ref $value eq "ARRAY" && @$value && @$value <= 100 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $value eq "ARRAY" and @$value and @$value <= 100
ref $value eq "ARRAY" and @$value
MC/DC0%0/3
ref $value eq "ARRAY" and @$value and @$value <= 100
ref $value eq "ARRAY"
@$value
@$value <= 100
Truth table0%0/4
A and B and C
A= ref $value eq "ARRAY"B= @$valueC= @$value <= 100
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | or die "SEARCH $key requires a nonempty array of filters\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my @groups = map [search_filter ($_, $depth + 1, $nodes)], @$value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ($key eq "all") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | push @criteria, @groups; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $or = pop @groups; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | $or = ["OR", pop @groups, $or] while @groups; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | push @criteria, @$or; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } elsif ($key eq "not") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | push @criteria, "NOT", [search_filter ($value, $depth + 1, $nodes)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } elsif ($key eq "header") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | ref $value eq "HASH" && keys %$value && keys %$value <= 20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $value eq "HASH" and keys %$value and keys %$value <= 20
ref $value eq "HASH" and keys %$value
MC/DC0%0/3
ref $value eq "HASH" and keys %$value and keys %$value <= 20
ref $value eq "HASH"
keys %$value
keys %$value <= 20
Truth table0%0/4
A and B and C
A= ref $value eq "HASH"B= keys %$valueC= keys %$value <= 20
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | or die "SEARCH header requires 1..20 header names\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | for my $name (sort keys %$value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | $name =~ /\A[A-Za-z0-9][A-Za-z0-9-]{0,62}\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | or die "Invalid SEARCH header name\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $text = $value->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | defined $text && !ref $text && length $text <= 500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $text and not ref $text and length $text <= 500
defined $text and not ref $text
MC/DC0%0/3
defined $text and not ref $text and length $text <= 500
defined $text
not ref $text
length $text <= 500
Truth table0%0/4
A and not(B) and C
A= defined $textB= not ref $textC= length $text <= 500
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | or die "Invalid SEARCH header value\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | push @criteria, "HEADER", $name, { Quote => $text }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } elsif ($key =~ /\A(?:from|to|cc|bcc|subject|body|text)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | defined $value && !ref $value && length $value <= 500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $value and not ref $value and length $value <= 500
defined $value and not ref $value
MC/DC0%0/3
defined $value and not ref $value and length $value <= 500
defined $value
not ref $value
length $value <= 500
Truth table0%0/4
A and not(B) and C
A= defined $valueB= not ref $valueC= length $value <= 500
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | or die "Invalid SEARCH $key value\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | push @criteria, uc $key, { Quote => $value }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } elsif ($key =~ /\A(?:since|before|on|sent_since|sent_before|sent_on)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | defined $value && !ref $value && $value =~ /\A[0-9]{1,2}-[A-Za-z]{3}-[0-9]{4}\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $value and not ref $value and $value =~ /\A[0-9]{1,2}-[A-Za-z]{3}-[0-9]{4}\z/u
defined $value and not ref $value
MC/DC0%0/3
defined $value and not ref $value and $value =~ /\A[0-9]{1,2}-[A-Za-z]{3}-[0-9]{4}\z/u
defined $value
not ref $value
$value =~ /\A[0-9]{1,2}-[A-Za-z]{3}-[0-9]{4}\z/u
Truth table0%0/4
A and not(B) and C
A= defined $valueB= not ref $valueC= $value =~ /\A[0-9]{1,2}-[A-Za-z]{3}-[0-9]{4}\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | or die "Invalid SEARCH $key date (D-Mon-YYYY)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | (my $command = uc $key) =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | push @criteria, $command, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | ▶ | } elsif ($key eq "larger" || $key eq "smaller") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$key eq "larger" or $key eq "smaller"
MC/DC0%0/2
$key eq "larger" or $key eq "smaller"
$key eq "larger"
$key eq "smaller"
Truth table0%0/3
A or B
A= $key eq "larger"B= $key eq "smaller"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | defined $value && !ref $value && $value =~ /\A[0-9]{1,10}\z/ && $value <= 4294967295 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $value and not ref $value and $value =~ /\A[0-9]{1,10}\z/u and $value <= 4294967295
defined $value and not ref $value and $value =~ /\A[0-9]{1,10}\z/u
defined $value and not ref $value
MC/DC0%0/4
defined $value and not ref $value and $value =~ /\A[0-9]{1,10}\z/u and $value <= 4294967295
defined $value
not ref $value
$value =~ /\A[0-9]{1,10}\z/u
$value <= 4294967295
Truth table0%0/5
A and not(B) and C and D
A= defined $valueB= not ref $valueC= $value =~ /\A[0-9]{1,10}\z/uD= $value <= 4294967295
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | or die "Invalid SEARCH $key size\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | push @criteria, uc $key, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } elsif ($key =~ /\A(?:seen|unseen|answered|unanswered|flagged|unflagged|deleted|undeleted|draft|undraft|recent|old|new)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | defined $value && "$value" =~ /\A[01]\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and "$value" =~ /\A[01]\z/u
MC/DC0%0/2
defined $value and "$value" =~ /\A[01]\z/u
defined $value
"$value" =~ /\A[01]\z/u
Truth table0%0/3
A and B
A= defined $valueB= "$value" =~ /\A[01]\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | or die "Invalid SEARCH $key boolean\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | push @criteria, uc $key if $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | die "Unknown SEARCH filter: $key\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | @criteria or !$depth or die "Empty SEARCH filter group\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@criteria or not $depth
MC/DC0%0/2
@criteria or not $depth
@criteria
not $depth
Truth table0%0/3
A or not(B)
A= @criteriaB= not $depth
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | @criteria | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub messages { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
messages: not called CC=62 SCAR=82.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $validity = mailbox ($args->{mailbox}, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $explicit = exists $args->{uids}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if ($explicit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | defined $args->{uidvalidity} && "$args->{uidvalidity}" eq "$validity" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args->{"uidvalidity"} and qq[$args->{"uidvalidity"}] eq "$validity"
MC/DC0%0/2
defined $args->{"uidvalidity"} and qq[$args->{"uidvalidity"}] eq "$validity"
defined $args->{"uidvalidity"}
qq[$args->{"uidvalidity"}] eq "$validity"
Truth table0%0/3
A and B
A= defined $args->{"uidvalidity"}B= qq[$args->{"uidvalidity"}] eq "$validity"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | or die "UIDVALIDITY mismatch (current $validity); refresh message references\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | !exists $args->{cursor} && !exists $args->{filter} && !exists $args->{limit} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | or die "Explicit UIDs cannot be combined with cursor, filter or limit\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $args->{"cursor"} or exists $args->{"filter"} or exists $args->{"limit"}
exists $args->{"cursor"} or exists $args->{"filter"}
MC/DC0%0/3
exists $args->{"cursor"} or exists $args->{"filter"} or exists $args->{"limit"}
exists $args->{"cursor"}
exists $args->{"filter"}
exists $args->{"limit"}
Truth table0%0/4
A or B or C
A= exists $args->{"cursor"}B= exists $args->{"filter"}C= exists $args->{"limit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | uids ($args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my $cursor = $args->{cursor}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if (defined $cursor) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | ref $cursor eq "HASH" && defined $cursor->{uidvalidity} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | && "$cursor->{uidvalidity}" eq "$validity" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | && defined $cursor->{before_uid} && $cursor->{before_uid} =~ /\A[1-9][0-9]*\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/12
ref $cursor eq "HASH" and defined $cursor->{"uidvalidity"} and qq[$cursor->{"uidvalidity"}] eq "$validity" and defined $cursor->{"before_uid"} and $cursor->{"before_uid"} =~ /\A[1-9][0-9]*\z/u
ref $cursor eq "HASH" and defined $cursor->{"uidvalidity"} and qq[$cursor->{"uidvalidity"}] eq "$validity" and defined $cursor->{"before_uid"}
ref $cursor eq "HASH" and defined $cursor->{"uidvalidity"} and qq[$cursor->{"uidvalidity"}] eq "$validity"
ref $cursor eq "HASH" and defined $cursor->{"uidvalidity"}
MC/DC0%0/5
ref $cursor eq "HASH" and defined $cursor->{"uidvalidity"} and qq[$cursor->{"uidvalidity"}] eq "$validity" and defined $cursor->{"before_uid"} and $cursor->{"before_uid"} =~ /\A[1-9][0-9]*\z/u
ref $cursor eq "HASH"
defined $cursor->{"uidvalidity"}
qq[$cursor->{"uidvalidity"}] eq "$validity"
defined $cursor->{"before_uid"}
$cursor->{"before_uid"} =~ /\A[1-9][0-9]*\z/u
Truth table0%0/6
A and B and C and D and E
A= ref $cursor eq "HASH"B= defined $cursor->{"uidvalidity"}C= qq[$cursor->{"uidvalidity"}] eq "$validity"D= defined $cursor->{"before_uid"}E= $cursor->{"before_uid"} =~ /\A[1-9][0-9]*\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | or die "Stale or invalid UID cursor\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $nodes = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | my @criteria = $explicit ? () : search_filter ($args->{filter} // {}, 0, \$nodes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$args->{"filter"} // {}
MC/DC0%0/1
$args->{"filter"} // {}
$args->{"filter"}
Truth table0%0/2
A
A= $args->{"filter"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my @fields = @{$args->{fields} || [qw(subject from date flags size)]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'fields'} || ['subject', 'from', 'date', 'flags', 'size']
MC/DC0%0/1
$args->{'fields'} || ['subject', 'from', 'date', 'flags', 'size']
$args->{'fields'}
Truth table0%0/2
A
A= $args->{'fields'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my %valid = map +($_ => 1), qw(uid from to subject date cc reply-to message-id flags size internaldate); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | $valid{$_} or die "Invalid summary field: $_\n" for @fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | my @headers = @{$args->{headers} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'headers'} || []
MC/DC0%0/1
$args->{'headers'} || []
$args->{'headers'}
Truth table0%0/2
A
A= $args->{'headers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | @headers <= 20 or die "Too many headers\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | for (@headers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | /\A[A-Za-z0-9][A-Za-z0-9-]{0,62}\z/ or die "Invalid header name: $_\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # search in descending UID windows: ordinary UID SEARCH can otherwise return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # millions of matches even when only one summary page was requested. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # Mail::IMAPTalk caches SELECT, so UIDNEXT from that SELECT becomes stale. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my ($more, $incomplete, $hi); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if ($explicit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | @found = @{$args->{uids}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | my $limit = $args->{limit} // 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"limit"} // 100
MC/DC0%0/1
$args->{"limit"} // 100
$args->{"limit"}
Truth table0%0/2
A
A= $args->{"limit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | $limit =~ /\A[1-9][0-9]*\z/ && $limit <= 1000 or die "limit must be 1..1000\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$limit =~ /\A[1-9][0-9]*\z/u and $limit <= 1000
MC/DC0%0/2
$limit =~ /\A[1-9][0-9]*\z/u and $limit <= 1000
$limit =~ /\A[1-9][0-9]*\z/u
$limit <= 1000
Truth table0%0/3
A and B
A= $limit =~ /\A[1-9][0-9]*\z/uB= $limit <= 1000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $status = checked ($imap->status ($args->{mailbox}, "(UIDNEXT UIDVALIDITY)"), "STATUS"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | "$status->{uidvalidity}" eq "$validity" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | or die "Mailbox UIDVALIDITY changed; restart mcp-imap\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $uidnext = $status->{uidnext}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | defined $uidnext && $uidnext =~ /\A[1-9][0-9]*\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $uidnext and $uidnext =~ /\A[1-9][0-9]*\z/u
MC/DC0%0/2
defined $uidnext and $uidnext =~ /\A[1-9][0-9]*\z/u
defined $uidnext
$uidnext =~ /\A[1-9][0-9]*\z/u
Truth table0%0/3
A and B
A= defined $uidnextB= $uidnext =~ /\A[1-9][0-9]*\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | or die "Server did not provide UIDNEXT\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | $hi = $args->{cursor} ? $args->{cursor}{before_uid} - 1 : $uidnext - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $scanned = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | while ($hi > 0 && $scanned < 20000 && @found <= $limit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$hi > 0 and $scanned < 20000 and @found <= $limit
$hi > 0 and $scanned < 20000
MC/DC0%0/3
$hi > 0 and $scanned < 20000 and @found <= $limit
$hi > 0
$scanned < 20000
@found <= $limit
Truth table0%0/4
A and B and C
A= $hi > 0B= $scanned < 20000C= @found <= $limit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my $lo = $hi > 999 ? $hi - 999 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $matches = checked ($imap->search ("$lo:$hi", @criteria), "UID SEARCH"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | push @found, sort { $b <=> $a } @$matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $scanned += $hi - $lo + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $hi = $lo - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $more = @found > $limit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | splice @found, $limit if $more; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | $incomplete = $hi > 0 && !$more; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$hi > 0 && !$more
MC/DC0%0/2
$hi > 0 && !$more
$hi > 0
!$more
Truth table0%0/3
A && not(B)
A= $hi > 0B= !$more
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my %selected = map +($_ => 1), @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my @items = ("uid"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | push @items, "envelope" if grep $selected{$_}, qw(from to subject date cc reply-to message-id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | push @items, "flags" if $selected{flags}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | push @items, "rfc822.size" if $selected{size}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | push @items, "internaldate" if $selected{internaldate}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if (@headers) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | push @items, "body.peek[header.fields (" . (join " ", @headers) . ")]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | my $data = @found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | ? checked ($imap->fetch (\@found, "(" . join (" ", @items) . ")"), "Fetch summaries") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my %env = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | (map +($_ => ucfirst $_), qw(from to subject date cc)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | "reply-to" => "Reply-To", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | "message-id" => "Message-ID", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my @messages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | for my $uid (@found) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | my $item = $data->{$uid} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my %row = (uid => 0 + $uid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | next if $field eq "uid"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $key = $env{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | $row{$field} = $key ? $item->{envelope}{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | : $field eq "size" ? $item->{"rfc822.size"} : $item->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $row{$field} = mime_header ($row{$field}) if $field =~ /\A(?:subject|from|to|cc|reply-to)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if (@headers) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | $row{headers} = $item->{headers} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$item->{'headers'} || {}
MC/DC0%0/1
$item->{'headers'} || {}
$item->{'headers'}
Truth table0%0/2
A
A= $item->{'headers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | length (JSON::XS->new->utf8->encode ($row{headers})) <= 65536 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | or die "Selected headers exceed 64 KiB\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | push @messages, \%row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | my $before = $explicit ? undef : $incomplete ? $hi + 1 : @found ? $found[-1] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | uidvalidity => $validity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | messages => \@messages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | more => $more || $incomplete ? JSON::XS::true : JSON::XS::false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | incomplete => $incomplete ? JSON::XS::true : JSON::XS::false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | ($explicit ? (missing_uids => [grep !$data->{$_}, @found]) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/9
$more or $incomplete
$more || $incomplete and $before
$more or $incomplete
MC/DC0%0/3
$more || $incomplete and $before
$more
$incomplete
$before
Truth table0%0/5
A or B and C
A= $moreB= $incompleteC= $before
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | next_cursor => ($more || $incomplete) && $before | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | ? { uidvalidity => $validity, before_uid => $before } : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | sub threads { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
threads: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my $validity = mailbox ($args->{mailbox}, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if (defined $args->{uidvalidity}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | "$args->{uidvalidity}" eq "$validity" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | or die "UIDVALIDITY mismatch (current $validity); refresh message references\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | $imap->capability->{"thread=orderedsubject"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | or die "IMAP server does not advertise THREAD=ORDEREDSUBJECT\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my $nodes = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | my @criteria = search_filter ($args->{filter} // {}, 0, \$nodes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"filter"} // {}
MC/DC0%0/1
$args->{"filter"} // {}
$args->{"filter"}
Truth table0%0/2
A
A= $args->{"filter"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $range = $args->{uid_range}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | if (defined $range) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | !ref $range && $range =~ /\A([1-9][0-9]{0,9}):([1-9][0-9]{0,9})\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $range and $range =~ /\A([1-9][0-9]{0,9}):([1-9][0-9]{0,9})\z/u
MC/DC0%0/2
not ref $range and $range =~ /\A([1-9][0-9]{0,9}):([1-9][0-9]{0,9})\z/u
not ref $range
$range =~ /\A([1-9][0-9]{0,9}):([1-9][0-9]{0,9})\z/u
Truth table0%0/3
not(A) and B
A= not ref $rangeB= $range =~ /\A([1-9][0-9]{0,9}):([1-9][0-9]{0,9})\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | or die "uid_range must be START:END (positive UIDs)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my ($lo, $hi) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | $lo <= $hi && $hi <= 4294967295 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lo <= $hi and $hi <= 4294967295
MC/DC0%0/2
$lo <= $hi and $hi <= 4294967295
$lo <= $hi
$hi <= 4294967295
Truth table0%0/3
A and B
A= $lo <= $hiB= $hi <= 4294967295
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | or die "uid_range must be ascending with 32-bit UIDs\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | unshift @criteria, "UID", $range; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | @criteria = ("ALL") unless @criteria; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $threads = checked ($imap->thread ("ORDEREDSUBJECT", "UTF-8", @criteria), "UID THREAD"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | uidvalidity => $validity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | (defined $range ? (uid_range => $range) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | threads => $threads, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | sub sort_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_page: not called CC=19 SCAR=59.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my ($args, $validity) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | my $snap = $sort_snapshot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | or die "No SORT snapshot (worker restarted or snapshot discarded); create a new one\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | defined $args->{snapshot_id} && $args->{snapshot_id} eq $snap->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | && $args->{mailbox} eq $snap->{mailbox} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | or die "Unknown or stale SORT snapshot ID\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $args->{"snapshot_id"} and $args->{"snapshot_id"} eq $snap->{"id"} and $args->{"mailbox"} eq $snap->{"mailbox"}
defined $args->{"snapshot_id"} and $args->{"snapshot_id"} eq $snap->{"id"}
MC/DC0%0/3
defined $args->{"snapshot_id"} and $args->{"snapshot_id"} eq $snap->{"id"} and $args->{"mailbox"} eq $snap->{"mailbox"}
defined $args->{"snapshot_id"}
$args->{"snapshot_id"} eq $snap->{"id"}
$args->{"mailbox"} eq $snap->{"mailbox"}
Truth table0%0/4
A and B and C
A= defined $args->{"snapshot_id"}B= $args->{"snapshot_id"} eq $snap->{"id"}C= $args->{"mailbox"} eq $snap->{"mailbox"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | $validity = mailbox ($args->{mailbox}, 0) unless defined $validity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | "$validity" eq "$snap->{uidvalidity}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | or die "SORT snapshot UIDVALIDITY changed; discard and recreate it\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | my $offset = $args->{offset} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"offset"} // 0
MC/DC0%0/1
$args->{"offset"} // 0
$args->{"offset"}
Truth table0%0/2
A
A= $args->{"offset"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | defined $offset && !ref $offset && $offset =~ /\A(?:0|[1-9][0-9]*)\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $offset and not ref $offset and $offset =~ /\A(?:0|[1-9][0-9]*)\z/u
defined $offset and not ref $offset
MC/DC0%0/3
defined $offset and not ref $offset and $offset =~ /\A(?:0|[1-9][0-9]*)\z/u
defined $offset
not ref $offset
$offset =~ /\A(?:0|[1-9][0-9]*)\z/u
Truth table0%0/4
A and not(B) and C
A= defined $offsetB= not ref $offsetC= $offset =~ /\A(?:0|[1-9][0-9]*)\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | or die "SORT offset must be nonnegative\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | my $limit = $args->{limit} // 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"limit"} // 100
MC/DC0%0/1
$args->{"limit"} // 100
$args->{"limit"}
Truth table0%0/2
A
A= $args->{"limit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | defined $limit && !ref $limit && $limit =~ /\A[1-9][0-9]*\z/ && $limit <= 1000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $limit and not ref $limit and $limit =~ /\A[1-9][0-9]*\z/u and $limit <= 1000
defined $limit and not ref $limit and $limit =~ /\A[1-9][0-9]*\z/u
defined $limit and not ref $limit
MC/DC0%0/4
defined $limit and not ref $limit and $limit =~ /\A[1-9][0-9]*\z/u and $limit <= 1000
defined $limit
not ref $limit
$limit =~ /\A[1-9][0-9]*\z/u
$limit <= 1000
Truth table0%0/5
A and not(B) and C and D
A= defined $limitB= not ref $limitC= $limit =~ /\A[1-9][0-9]*\z/uD= $limit <= 1000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | or die "SORT limit must be 1..1000\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $count = @{$snap->{uids}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | $offset <= $count or die "SORT offset beyond snapshot\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | my $end = $offset + $limit < $count ? $offset + $limit : $count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | snapshot_id => $snap->{id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | uidvalidity => $validity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | count => $count, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | offset => 0 + $offset, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | uids => [@{$snap->{uids}}[$offset .. $end - 1]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | next_offset => $end < $count ? $end : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | sub sort_create { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_create: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $validity = mailbox ($args->{mailbox}, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | $imap->capability->{sort} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | or die "IMAP server does not advertise SORT\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | my $limit = $args->{limit} // 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"limit"} // 100
MC/DC0%0/1
$args->{"limit"} // 100
$args->{"limit"}
Truth table0%0/2
A
A= $args->{"limit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | defined $limit && !ref $limit && $limit =~ /\A[1-9][0-9]*\z/ && $limit <= 1000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $limit and not ref $limit and $limit =~ /\A[1-9][0-9]*\z/u and $limit <= 1000
defined $limit and not ref $limit and $limit =~ /\A[1-9][0-9]*\z/u
defined $limit and not ref $limit
MC/DC0%0/4
defined $limit and not ref $limit and $limit =~ /\A[1-9][0-9]*\z/u and $limit <= 1000
defined $limit
not ref $limit
$limit =~ /\A[1-9][0-9]*\z/u
$limit <= 1000
Truth table0%0/5
A and not(B) and C and D
A= defined $limitB= not ref $limitC= $limit =~ /\A[1-9][0-9]*\z/uD= $limit <= 1000
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | or die "SORT limit must be 1..1000\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my $nodes = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | my @criteria = search_filter ($args->{filter} // {}, 0, \$nodes); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"filter"} // {}
MC/DC0%0/1
$args->{"filter"} // {}
$args->{"filter"}
Truth table0%0/2
A
A= $args->{"filter"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | @criteria = ("ALL") unless @criteria; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $uids = checked ($imap->sort ("(SUBJECT DATE)", "UTF-8", @criteria), "UID SORT"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | ref $uids eq "ARRAY" or die "Invalid UID SORT result\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | my $id = unpack "H*", AnyEvent::MCP::random_bytes 16; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | $sort_snapshot = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | id => $id, mailbox => $args->{mailbox}, uidvalidity => $validity, uids => $uids, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | sort_page ({ mailbox => $args->{mailbox}, snapshot_id => $id, limit => $limit }, $validity) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | sub sort_discard { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_discard: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | my $snap = $sort_snapshot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | or die "No SORT snapshot (worker restarted or snapshot discarded)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | defined $args->{snapshot_id} && $args->{snapshot_id} eq $snap->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | && $args->{mailbox} eq $snap->{mailbox} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | or die "Unknown or stale SORT snapshot ID\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $args->{"snapshot_id"} and $args->{"snapshot_id"} eq $snap->{"id"} and $args->{"mailbox"} eq $snap->{"mailbox"}
defined $args->{"snapshot_id"} and $args->{"snapshot_id"} eq $snap->{"id"}
MC/DC0%0/3
defined $args->{"snapshot_id"} and $args->{"snapshot_id"} eq $snap->{"id"} and $args->{"mailbox"} eq $snap->{"mailbox"}
defined $args->{"snapshot_id"}
$args->{"snapshot_id"} eq $snap->{"id"}
$args->{"mailbox"} eq $snap->{"mailbox"}
Truth table0%0/4
A and B and C
A= defined $args->{"snapshot_id"}B= $args->{"snapshot_id"} eq $snap->{"id"}C= $args->{"mailbox"} eq $snap->{"mailbox"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | undef $sort_snapshot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | +{ ok => JSON::XS::true } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | sub preview_parts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preview_parts: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | return unless ref $node eq "HASH"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | return if lc ($node->{"Disposition-Type"} || "") eq "attachment"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$node->{'Disposition-Type'} || ''
MC/DC0%0/1
$node->{'Disposition-Type'} || ''
$node->{'Disposition-Type'}
Truth table0%0/2
A
A= $node->{'Disposition-Type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | return $node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | if lc ($node->{"MIME-Type"} || "") eq "text" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | && lc ($node->{"MIME-Subtype"} || "") =~ /\A(?:plain|html)\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | && ($node->{"IMAP-Partnum"} // "") =~ /\A[1-9][0-9]*(?:\.[1-9][0-9]*)*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/12
lc($node->{"MIME-Type"} || "") eq "text" and lc($node->{"MIME-Subtype"} or "") =~ /\A(?:plain|html)\z/u and ($node->{"IMAP-Partnum"} // "") =~ /\A[1-9][0-9]*(?:\.[1-9][0-9]*)*\z/u
lc($node->{"MIME-Type"} || "") eq "text" and lc($node->{"MIME-Subtype"} or "") =~ /\A(?:plain|html)\z/u
$node->{'MIME-Type'} || ''
$node->{'MIME-Subtype'} || ''
$node->{"IMAP-Partnum"} // ""
MC/DC0%0/3
lc($node->{"MIME-Type"} || "") eq "text" and lc($node->{"MIME-Subtype"} or "") =~ /\A(?:plain|html)\z/u and ($node->{"IMAP-Partnum"} // "") =~ /\A[1-9][0-9]*(?:\.[1-9][0-9]*)*\z/u
$node->{'MIME-Type'}
$node->{'MIME-Subtype'}
$node->{"IMAP-Partnum"}
Truth table0%0/4
A and B and C
A= $node->{'MIME-Type'}B= $node->{'MIME-Subtype'}C= $node->{"IMAP-Partnum"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | map preview_parts ($_), @{$node->{"MIME-Subparts"} || []} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$node->{'MIME-Subparts'} || []
MC/DC0%0/1
$node->{'MIME-Subparts'} || []
$node->{'MIME-Subparts'}
Truth table0%0/2
A
A= $node->{'MIME-Subparts'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | sub preview_attachments { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preview_attachments: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | my ($node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | return unless ref $node eq "HASH"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | my $type = lc ($node->{"MIME-TxtType"} || ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$node->{'MIME-TxtType'} || ''
MC/DC0%0/1
$node->{'MIME-TxtType'} || ''
$node->{'MIME-TxtType'}
Truth table0%0/2
A
A= $node->{'MIME-TxtType'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | my $disposition = lc ($node->{"Disposition-Type"} || ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$node->{'Disposition-Type'} || ''
MC/DC0%0/1
$node->{'Disposition-Type'} || ''
$node->{'Disposition-Type'}
Truth table0%0/2
A
A= $node->{'Disposition-Type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | my $name = $node->{"Content-Disposition"}{filename} // $node->{"Content-Type"}{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$node->{"Content-Disposition"}{"filename"} // $node->{"Content-Type"}{"name"}
MC/DC0%0/2
$node->{"Content-Disposition"}{"filename"} // $node->{"Content-Type"}{"name"}
$node->{"Content-Disposition"}{"filename"}
$node->{"Content-Type"}{"name"}
Truth table0%0/3
A // B
A= $node->{"Content-Disposition"}{"filename"}B= $node->{"Content-Type"}{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if ($node->{"IMAP-Partnum"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/12
$node->{"IMAP-Partnum"} and $disposition eq "attachment" || defined $name || $type =~ m[\A(?:image|audio|video|application|message)/]u || $type =~ m[\Atext/(?!plain\z|html\z)]u
$disposition eq "attachment" or defined $name or $type =~ m[\A(?:image|audio|video|application|message)/]u or $type =~ m[\Atext/(?!plain\z|html\z)]u
$disposition eq "attachment" or defined $name or $type =~ m[\A(?:image|audio|video|application|message)/]u
$disposition eq "attachment" or defined $name
MC/DC0%0/5
$node->{"IMAP-Partnum"} and $disposition eq "attachment" || defined $name || $type =~ m[\A(?:image|audio|video|application|message)/]u || $type =~ m[\Atext/(?!plain\z|html\z)]u
$node->{"IMAP-Partnum"}
$disposition eq "attachment"
defined $name
$type =~ m[\A(?:image|audio|video|application|message)/]u
$type =~ m[\Atext/(?!plain\z|html\z)]u
Truth table0%0/6
A and B or C or D or E
A= $node->{"IMAP-Partnum"}B= $disposition eq "attachment"C= defined $nameD= $type =~ m[\A(?:image|audio|video|application|message)/]uE= $type =~ m[\Atext/(?!plain\z|html\z)]u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | && ($disposition eq "attachment" || defined $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | || $type =~ m!\A(?:image|audio|video|application|message)/! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | || $type =~ m{\Atext/(?!plain\z|html\z)})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my $size = $node->{Size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | return +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | part => $node->{"IMAP-Partnum"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
defined $size and $size =~ /\A\d+\z/u
MC/DC0%0/2
defined $size and $size =~ /\A\d+\z/u
defined $size
$size =~ /\A\d+\z/u
Truth table0%0/3
A and B
A= defined $sizeB= $size =~ /\A\d+\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | (defined $name ? (name => mime_header ($name)) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | (defined $size && $size =~ /\A\d+\z/ ? (size => 0 + $size) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | ($disposition ? (disposition => $disposition) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | map preview_attachments ($_), @{$node->{"MIME-Subparts"} || []} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$node->{'MIME-Subparts'} || []
MC/DC0%0/1
$node->{'MIME-Subparts'} || []
$node->{'MIME-Subparts'}
Truth table0%0/2
A
A= $node->{'MIME-Subparts'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | sub preview_html { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preview_html: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | my ($html) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | require HTML::Parser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my ($text, $skip, @links) = ("", 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | my $parser = HTML::Parser->new ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | api_version => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | start_h => [sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my ($tag, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | if ($tag =~ /\A(?:head|script|style|title)\z/) { ++$skip; return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | return if $skip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | $text .= "\n" if $tag =~ /\A(?:br|p|div|li|tr|h[1-6])\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | push @links, [$attr->{href} // "", length $text] if $tag eq "a"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$attr->{"href"} // ""
MC/DC0%0/1
$attr->{"href"} // ""
$attr->{"href"}
Truth table0%0/2
A
A= $attr->{"href"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | }, "tagname,attr"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | end_h => [sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my ($tag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | if ($tag =~ /\A(?:head|script|style|title)\z/) { --$skip if $skip; return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | return if $skip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if ($tag eq "a" && @links) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tag eq "a" and @links
MC/DC0%0/2
$tag eq "a" and @links
$tag eq "a"
@links
Truth table0%0/3
A and B
A= $tag eq "a"B= @links
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | my ($url, $start) = @{pop @links}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | $text .= " ($url)" if $url =~ /\A(?:https?:\/\/|mailto:)/i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$url =~ m[\A(?:https?://|mailto:)]iu and not substr($text, $start) =~ /\Q$url\E/u
MC/DC0%0/2
$url =~ m[\A(?:https?://|mailto:)]iu and not substr($text, $start) =~ /\Q$url\E/u
$url =~ m[\A(?:https?://|mailto:)]iu
not substr($text, $start) =~ /\Q$url\E/u
Truth table0%0/3
A and not(B)
A= $url =~ m[\A(?:https?://|mailto:)]iuB= not substr($text, $start) =~ /\Q$url\E/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | && substr ($text, $start) !~ /\Q$url\E/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | $text .= "\n" if $tag =~ /\A(?:p|div|li|tr|h[1-6])\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | }, "tagname"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | text_h => [sub { $text .= $_[0] unless $skip }, "dtext"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $parser->parse ($html); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $parser->eof; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $text =~ s/[\t \x{a0}]+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $text =~ s/ *\n */\n/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $text =~ s/\n{3,}/\n\n/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $text =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $text | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | sub preview_decode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preview_decode: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my ($part, $bytes, $max) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | defined $bytes && !ref $bytes or die "Missing MIME part data\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $bytes and not ref $bytes
MC/DC0%0/2
defined $bytes and not ref $bytes
defined $bytes
not ref $bytes
Truth table0%0/3
A and not(B)
A= defined $bytesB= not ref $bytes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $truncated = length $bytes > $max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | substr ($bytes, $max) = "" if $truncated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | my $encoding = uc ($part->{"Content-Transfer-Encoding"} || "7BIT"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$part->{'Content-Transfer-Encoding'} || '7BIT'
MC/DC0%0/1
$part->{'Content-Transfer-Encoding'} || '7BIT'
$part->{'Content-Transfer-Encoding'}
Truth table0%0/2
A
A= $part->{'Content-Transfer-Encoding'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if ($encoding eq "BASE64") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $bytes =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | substr ($bytes, length ($bytes) - length ($bytes) % 4) = "" if $truncated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $bytes = MIME::Base64::decode_base64 ($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } elsif ($encoding eq "QUOTED-PRINTABLE") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | $bytes =~ s/=(?:[0-9A-Fa-f]|\r)?\z// if $truncated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $bytes = MIME::QuotedPrint::decode_qp ($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } elsif ($encoding !~ /\A(?:7BIT|8BIT|BINARY)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | die "Unsupported transfer encoding $encoding\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | my $charset = $part->{"Content-Type"}{charset} || "us-ascii"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$part->{'Content-Type'}{'charset'} || 'us-ascii'
MC/DC0%0/1
$part->{'Content-Type'}{'charset'} || 'us-ascii'
$part->{'Content-Type'}{'charset'}
Truth table0%0/2
A
A= $part->{'Content-Type'}{'charset'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my $text = Encode::decode ($charset, $bytes, Encode::FB_QUIET ()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | my $error = length $bytes && !$truncated ? "Invalid $charset text encoding" : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $bytes and not $truncated
MC/DC0%0/2
length $bytes and not $truncated
length $bytes
not $truncated
Truth table0%0/3
A and not(B)
A= length $bytesB= not $truncated
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my $type = lc $part->{"MIME-Subtype"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | $text = preview_html ($text) if $type eq "html"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | text => $text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | content_type => "text/$type", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | part => $part->{"IMAP-Partnum"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | truncated => $truncated ? JSON::XS::true : JSON::XS::false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | (defined $error ? (error => $error) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # One UID FETCH per distinct MIME part number, never per message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | sub preview_fetch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preview_fetch: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my ($parts, $max) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my %group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | push @{$group{$parts->{$_}{"IMAP-Partnum"}}}, $_ for keys %$parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my %result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | for my $part (keys %group) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | my $f = checked ($imap->fetch ($group{$part}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | "body.peek[$part]<0." . ($max + 1) . ">"), "Fetch preview $part"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | for my $uid (@{$group{$part}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | $result{$uid} = eval { preview_decode ($parts->{$uid}, $f->{$uid}{body}, $max) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
eval {
do {
preview_decode($parts->{$uid}, $f->{$uid}{'body'}, $max)
}
} || {'error', "$@" || 'Unable to decode preview'}
"$@" || 'Unable to decode preview'
MC/DC0%0/1
eval {
do {
preview_decode($parts->{$uid}, $f->{$uid}{'body'}, $max)
}
} || {'error', "$@" || 'Unable to decode preview'}
eval {
do {
preview_decode($parts->{$uid}, $f->{$uid}{'body'}, $max)
}
}
MC/DC0%0/1
"$@" || 'Unable to decode preview'
"$@"
Truth table0%0/2
A
A= eval {
do {
preview_decode($parts->{$uid}, $f->{$uid}{'body'}, $max)
}
}
Truth table0%0/2
A
A= "$@"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | || { error => "$@" || "Unable to decode preview" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | \%result | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | sub previews { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
previews: not called CC=29 SCAR=67.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my $validity = same_validity ($args, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $uids = $args->{uids}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | uids ($args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | @$uids <= 25 or die "previews limited to 25 UIDs\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | my $max = $args->{max_bytes} // 2048; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"max_bytes"} // 2048
MC/DC0%0/1
$args->{"max_bytes"} // 2048
$args->{"max_bytes"}
Truth table0%0/2
A
A= $args->{"max_bytes"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | $max =~ /\A[1-9][0-9]*\z/ && $max <= 4096 or die "max_bytes must be 1..4096\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$max =~ /\A[1-9][0-9]*\z/u and $max <= 4096
MC/DC0%0/2
$max =~ /\A[1-9][0-9]*\z/u and $max <= 4096
$max =~ /\A[1-9][0-9]*\z/u
$max <= 4096
Truth table0%0/3
A and B
A= $max =~ /\A[1-9][0-9]*\z/uB= $max <= 4096
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | my $f = checked ($imap->fetch ($uids, "bodystructure"), "Fetch MIME structures"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | my (%primary, %fallback, %missing, %attachments); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | for my $uid (@$uids) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my $item = $f->{$uid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | my @parts = preview_parts ($item ? $item->{bodystructure} : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | $attachments{$uid} = [preview_attachments ($item->{bodystructure})] if $item; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my ($plain) = grep lc ($_ ->{"MIME-Subtype"}) eq "plain", @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | my ($html) = grep lc ($_ ->{"MIME-Subtype"}) eq "html", @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | $primary{$uid} = $plain || $html if $plain || $html; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$plain or $html
$plain || $html
MC/DC0%0/2
$plain or $html
$plain
$html
MC/DC0%0/2
$plain || $html
$plain
$html
Truth table0%0/3
A or B
A= $plainB= $html
Truth table0%0/3
A || B
A= $plainB= $html
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | $fallback{$uid} = $html if $plain && $html; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$plain and $html
MC/DC0%0/2
$plain and $html
$plain
$html
Truth table0%0/3
A and B
A= $plainB= $html
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | $missing{$uid} = $item ? "No text MIME part" : "Message vanished" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$plain or $html
MC/DC0%0/2
$plain or $html
$plain
$html
Truth table0%0/3
A or B
A= $plainB= $html
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | unless $plain || $html; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $result = preview_fetch (\%primary, $max); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my %retry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | for my $uid (keys %fallback) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | my $text = $result->{$uid}{text} // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result->{$uid}{"text"} // ""
MC/DC0%0/1
$result->{$uid}{"text"} // ""
$result->{$uid}{"text"}
Truth table0%0/2
A
A= $result->{$uid}{"text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | $retry{$uid} = $fallback{$uid} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $text < 120 or $text =~ /(?:view (?:this |the )?(?:mail|message|email) (?:on|in) (?:the )?(?:web|browser)|click here)/iu
MC/DC0%0/2
length $text < 120 or $text =~ /(?:view (?:this |the )?(?:mail|message|email) (?:on|in) (?:the )?(?:web|browser)|click here)/iu
length $text < 120
$text =~ /(?:view (?:this |the )?(?:mail|message|email) (?:on|in) (?:the )?(?:web|browser)|click here)/iu
Truth table0%0/3
A or B
A= length $text < 120B= $text =~ /(?:view (?:this |the )?(?:mail|message|email) (?:on|in) (?:the )?(?:web|browser)|click here)/iu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | if length ($text) < 120 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | || $text =~ /(?:view (?:this |the )?(?:mail|message|email) (?:on|in) (?:the )?(?:web|browser)|click here)/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if (%retry) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | my $html = preview_fetch (\%retry, $max); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | for my $uid (keys %retry) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my $new = $html->{$uid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my $old = $result->{$uid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | $result->{$uid} = $new if defined $new->{text} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | && (!defined $old->{text} || length ($new->{text}) > length ($old->{text})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $new->{"text"} and !defined($old->{"text"}) || length $new->{"text"} > length $old->{"text"}
not defined $old->{"text"} or length $new->{"text"} > length $old->{"text"}
MC/DC0%0/3
defined $new->{"text"} and !defined($old->{"text"}) || length $new->{"text"} > length $old->{"text"}
defined $new->{"text"}
not defined $old->{"text"}
length $new->{"text"} > length $old->{"text"}
Truth table0%0/4
A and not(B) or C
A= defined $new->{"text"}B= not defined $old->{"text"}C= length $new->{"text"} > length $old->{"text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | uidvalidity => $validity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | previews => [map +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | uid => 0 + $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | %{$result->{$_} || { error => $missing{$_} || "No preview" }}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$result->{$_} || {'error', $missing{$_} || 'No preview'}
$missing{$_} || 'No preview'
MC/DC0%0/1
$result->{$_} || {'error', $missing{$_} || 'No preview'}
$result->{$_}
MC/DC0%0/1
$missing{$_} || 'No preview'
$missing{$_}
Truth table0%0/2
A
A= $result->{$_}
Truth table0%0/2
A
A= $missing{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | (@{$attachments{$_} || []} ? (attachments => $attachments{$_}) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$attachments{$_} || []
MC/DC0%0/1
$attachments{$_} || []
$attachments{$_}
Truth table0%0/2
A
A= $attachments{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | }, @$uids], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | sub part { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part: not called CC=25 SCAR=64.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my ($args, $raw_message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $validity = same_validity ($args, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my $uid = $args->{uid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | my $part = $raw_message ? "" : $args->{part}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | defined $part && $part =~ /\A(?:[1-9][0-9]*(?:\.[1-9][0-9]*)*)?\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $part and $part =~ /\A(?:[1-9][0-9]*(?:\.[1-9][0-9]*)*)?\z/u
MC/DC0%0/2
defined $part and $part =~ /\A(?:[1-9][0-9]*(?:\.[1-9][0-9]*)*)?\z/u
defined $part
$part =~ /\A(?:[1-9][0-9]*(?:\.[1-9][0-9]*)*)?\z/u
Truth table0%0/3
A and B
A= defined $partB= $part =~ /\A(?:[1-9][0-9]*(?:\.[1-9][0-9]*)*)?\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | or die "Invalid MIME part number\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | my $max = $args->{max_bytes} || 65536; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'max_bytes'} || 65536
MC/DC0%0/1
$args->{'max_bytes'} || 65536
$args->{'max_bytes'}
Truth table0%0/2
A
A= $args->{'max_bytes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | $max =~ /\A[1-9][0-9]*\z/ && $max <= 262144 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$max =~ /\A[1-9][0-9]*\z/u and $max <= 262144
MC/DC0%0/2
$max =~ /\A[1-9][0-9]*\z/u and $max <= 262144
$max =~ /\A[1-9][0-9]*\z/u
$max <= 262144
Truth table0%0/3
A and B
A= $max =~ /\A[1-9][0-9]*\z/uB= $max <= 262144
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | or die "max_bytes must be 1..262144\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | my $f = checked ($imap->fetch ($uid, "body.peek[$part]<0." . ($max + 1) . ">"), "Fetch part $uid"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | my $item = $f->{$uid} or die "Message $uid vanished\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | my $bytes = $item->{body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | defined $bytes && !ref $bytes or die "Invalid part data\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $bytes and not ref $bytes
MC/DC0%0/2
defined $bytes and not ref $bytes
defined $bytes
not ref $bytes
Truth table0%0/3
A and not(B)
A= defined $bytesB= not ref $bytes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | my $truncated = length $bytes > $max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | substr ($bytes, $max) = "" if $truncated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | my $result = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | uid => 0 + $uid, uidvalidity => $validity, part => $part, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | data_base64 => MIME::Base64::encode_base64 ($bytes, ""), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | truncated => $truncated ? JSON::XS::true : JSON::XS::false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | if ($args->{decode_text} && !$truncated && !$raw_message) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$args->{"decode_text"} and not $truncated and not $raw_message
$args->{"decode_text"} and not $truncated
MC/DC0%0/3
$args->{"decode_text"} and not $truncated and not $raw_message
$args->{"decode_text"}
not $truncated
not $raw_message
Truth table0%0/4
A and not(B) and not(C)
A= $args->{"decode_text"}B= not $truncatedC= not $raw_message
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my $bs = checked ($imap->fetch ($uid, "bodystructure"), "Fetch MIME structure")->{$uid}{bodystructure}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | my @pending = ($bs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | while (@pending) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my $candidate = shift @pending; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | if (($candidate->{"IMAP-Partnum"} // "") eq $part && $candidate->{"MIME-Type"} eq "text") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
($candidate->{"IMAP-Partnum"} // "") eq $part and $candidate->{"MIME-Type"} eq "text"
$candidate->{"IMAP-Partnum"} // ""
MC/DC0%0/2
($candidate->{"IMAP-Partnum"} // "") eq $part and $candidate->{"MIME-Type"} eq "text"
$candidate->{"IMAP-Partnum"}
$candidate->{"MIME-Type"} eq "text"
Truth table0%0/3
A and B
A= $candidate->{"IMAP-Partnum"}B= $candidate->{"MIME-Type"} eq "text"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | $node = $candidate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | push @pending, @{$candidate->{"MIME-Subparts"} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$candidate->{'MIME-Subparts'} || []
MC/DC0%0/1
$candidate->{'MIME-Subparts'} || []
$candidate->{'MIME-Subparts'}
Truth table0%0/2
A
A= $candidate->{'MIME-Subparts'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | $node or die "Part is not a text MIME leaf\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | my $encoding = uc ($node->{"Content-Transfer-Encoding"} || ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$node->{'Content-Transfer-Encoding'} || ''
MC/DC0%0/1
$node->{'Content-Transfer-Encoding'} || ''
$node->{'Content-Transfer-Encoding'}
Truth table0%0/2
A
A= $node->{'Content-Transfer-Encoding'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | $bytes = MIME::Base64::decode_base64 ($bytes) if $encoding eq "BASE64"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | $bytes = MIME::QuotedPrint::decode_qp ($bytes) if $encoding eq "QUOTED-PRINTABLE"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | ▶ | my $charset = $node->{"Content-Type"}{charset} || "us-ascii"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$node->{'Content-Type'}{'charset'} || 'us-ascii'
MC/DC0%0/1
$node->{'Content-Type'}{'charset'} || 'us-ascii'
$node->{'Content-Type'}{'charset'}
Truth table0%0/2
A
A= $node->{'Content-Type'}{'charset'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | $result->{text} = Encode::decode ($charset, $bytes, Encode::FB_CROAK ()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | $result->{content_type} = $node->{"MIME-TxtType"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | $result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=71 SCAR=85.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | my ($cmd, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $result = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if ($cmd eq "connect") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | undef $sort_snapshot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | return (1, imap_connect ($args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | return (1, sort_discard ($args)) if $cmd eq "sort_discard"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | if ($cmd eq "ping") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | $imap && $imap->is_open or die "IMAP connection closed during keepalive\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$imap and $imap->is_open
MC/DC0%0/2
$imap and $imap->is_open
$imap
$imap->is_open
Truth table0%0/3
A and B
A= $imapB= $imap->is_open
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my $timeout = "IMAP keepalive timed out\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | local $SIG{__WARN__} = sub { CORE::warn @_ unless $_[0] eq $timeout }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | local $SIG{ALRM} = sub { die $timeout }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | alarm 30; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | checked ($imap->noop, "NOOP"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | alarm 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | die $error if $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | return (1, { ok => JSON::XS::true }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | $imap && $imap->is_open or imap_connect $config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$imap and $imap->is_open
MC/DC0%0/2
$imap and $imap->is_open
$imap
$imap->is_open
Truth table0%0/3
A and B
A= $imapB= $imap->is_open
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | if ($cmd eq "mailboxes" || $cmd eq "lsub") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 13 branches
Condition0%0/3
$cmd eq "mailboxes" or $cmd eq "lsub"
MC/DC0%0/2
$cmd eq "mailboxes" or $cmd eq "lsub"
$cmd eq "mailboxes"
$cmd eq "lsub"
Truth table0%0/3
A or B
A= $cmd eq "mailboxes"B= $cmd eq "lsub"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | my $method = $cmd eq "lsub" ? "lsub" : "list"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | return (1, { mailboxes => checked ($imap->$method ("", "*"), uc $method) }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } elsif ($cmd eq "messages") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | return (1, messages ($args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } elsif ($cmd eq "threads") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | return (1, threads ($args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } elsif ($cmd eq "sort_create") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | return (1, sort_create ($args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } elsif ($cmd eq "sort_page") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | return (1, sort_page ($args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } elsif ($cmd eq "previews") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | return (1, previews ($args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } elsif ($cmd eq "message") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | return (1, message ($args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | ▶ | } elsif ($cmd eq "part" || $cmd eq "raw") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$cmd eq "part" or $cmd eq "raw"
MC/DC0%0/2
$cmd eq "part" or $cmd eq "raw"
$cmd eq "part"
$cmd eq "raw"
Truth table0%0/3
A or B
A= $cmd eq "part"B= $cmd eq "raw"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | return (1, part ($args, $cmd eq "raw")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } elsif ($cmd eq "flags") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my $validity = same_validity ($args, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | my $uidset = uids ($args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | $args->{operation} =~ /\A(?:add|remove)\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | or die "Invalid flag operation\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my $flags = $args->{flags}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | ref $flags eq "ARRAY" && @$flags && @$flags <= 20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $flags eq "ARRAY" and @$flags and @$flags <= 20
ref $flags eq "ARRAY" and @$flags
MC/DC0%0/3
ref $flags eq "ARRAY" and @$flags and @$flags <= 20
ref $flags eq "ARRAY"
@$flags
@$flags <= 20
Truth table0%0/4
A and B and C
A= ref $flags eq "ARRAY"B= @$flagsC= @$flags <= 20
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | or die "flags must be an array of 1..20 flags\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | for (@$flags) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | /\A(?:\\(?:Seen|Flagged|Answered|Deleted|Draft)|[A-Za-z][A-Za-z0-9_-]{0,63})\z/i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | or die "Invalid IMAP flag\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | checked ($imap->store ($uidset, ($args->{operation} eq "add" ? "+" : "-") . "flags.silent", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | "(" . join (" ", @$flags) . ")"), "STORE"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | return (1, { ok => JSON::XS::true, uidvalidity => $validity, uids => $args->{uids} }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | ▶ | } elsif ($cmd eq "copy" || $cmd eq "move") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$cmd eq "copy" or $cmd eq "move"
MC/DC0%0/2
$cmd eq "copy" or $cmd eq "move"
$cmd eq "copy"
$cmd eq "move"
Truth table0%0/3
A or B
A= $cmd eq "copy"B= $cmd eq "move"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | my $validity = same_validity ($args, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | my $uidset = uids ($args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | $cmd ne "move" || $imap->capability->{move} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | or die "Server does not advertise MOVE; refusing unsafe fallback\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$cmd ne "move" or $imap->capability->{"move"}
MC/DC0%0/2
$cmd ne "move" or $imap->capability->{"move"}
$cmd ne "move"
$imap->capability->{"move"}
Truth table0%0/3
A or B
A= $cmd ne "move"B= $imap->capability->{"move"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | checked ($imap->$cmd ($uidset, $args->{destination}), uc $cmd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | return (1, { ok => JSON::XS::true, uidvalidity => $validity, uids => $args->{uids} }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } elsif ($cmd eq "append") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | defined $args->{data_base64} && !ref $args->{data_base64} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | && length $args->{data_base64} <= 1398112 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | && $args->{data_base64} =~ /\A(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $args->{"data_base64"} and not ref $args->{"data_base64"} and length $args->{"data_base64"} <= 1398112 and $args->{"data_base64"} =~ m[\A(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\z]u
defined $args->{"data_base64"} and not ref $args->{"data_base64"} and length $args->{"data_base64"} <= 1398112
defined $args->{"data_base64"} and not ref $args->{"data_base64"}
MC/DC0%0/4
defined $args->{"data_base64"} and not ref $args->{"data_base64"} and length $args->{"data_base64"} <= 1398112 and $args->{"data_base64"} =~ m[\A(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\z]u
defined $args->{"data_base64"}
not ref $args->{"data_base64"}
length $args->{"data_base64"} <= 1398112
$args->{"data_base64"} =~ m[\A(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\z]u
Truth table0%0/5
A and not(B) and C and D
A= defined $args->{"data_base64"}B= not ref $args->{"data_base64"}C= length $args->{"data_base64"} <= 1398112D= $args->{"data_base64"} =~ m[\A(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\z]u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | or die "Invalid or oversized Base64 message\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my $bytes = MIME::Base64::decode_base64 ($args->{data_base64}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | length $bytes <= 1048576 or die "APPEND limited to 1 MiB\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | $bytes =~ /\r\n/ or die "APPEND expects an RFC 5322 message with CRLF line endings\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | unless ($config->{allow_mbox_from}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | my $line = mbox_from ($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | die "APPEND refused: raw message line $line resembles an unescaped mboxo From_ separator " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | . "(starts with 'From ' and has date-like text). Some mbox servers may mistake it " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | . "for a new message boundary. No APPEND attempted. Escape the line, or ask the " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | . "server operator to use --allow-mbox-from.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | if $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | ref $args->{flags} eq "ARRAY" || !defined $args->{flags} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | or die "Invalid flags\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $args->{"flags"} eq "ARRAY" or not defined $args->{"flags"}
MC/DC0%0/2
ref $args->{"flags"} eq "ARRAY" or not defined $args->{"flags"}
ref $args->{"flags"} eq "ARRAY"
not defined $args->{"flags"}
Truth table0%0/3
A or not(B)
A= ref $args->{"flags"} eq "ARRAY"B= not defined $args->{"flags"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | for (@{$args->{flags} || []}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'flags'} || []
MC/DC0%0/1
$args->{'flags'} || []
$args->{'flags'}
Truth table0%0/2
A
A= $args->{'flags'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | defined $_ && !ref $_ && /\A(?:\\(?:Seen|Flagged|Answered|Deleted|Draft)|[A-Za-z][A-Za-z0-9_-]{0,63})\z/i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $_ and not ref $_ and /\A(?:\\(?:Seen|Flagged|Answered|Deleted|Draft)|[A-Za-z][A-Za-z0-9_-]{0,63})\z/iu
defined $_ and not ref $_
MC/DC0%0/3
defined $_ and not ref $_ and /\A(?:\\(?:Seen|Flagged|Answered|Deleted|Draft)|[A-Za-z][A-Za-z0-9_-]{0,63})\z/iu
defined $_
not ref $_
/\A(?:\\(?:Seen|Flagged|Answered|Deleted|Draft)|[A-Za-z][A-Za-z0-9_-]{0,63})\z/iu
Truth table0%0/4
A and not(B) and C
A= defined $_B= not ref $_C= /\A(?:\\(?:Seen|Flagged|Answered|Deleted|Draft)|[A-Za-z][A-Za-z0-9_-]{0,63})\z/iu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | or die "Invalid IMAP flag\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my @extra = $args->{flags} && @{$args->{flags}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | ? ("(" . (join " ", @{$args->{flags}}) . ")") : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"flags"} and @{$args->{"flags"};}
MC/DC0%0/2
$args->{"flags"} and @{$args->{"flags"};}
$args->{"flags"}
@{$args->{"flags"};}
Truth table0%0/3
A and B
A= $args->{"flags"}B= @{$args->{"flags"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | checked ($imap->append ($args->{mailbox}, @extra, { Literal => $bytes }), "APPEND"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | return (1, { ok => JSON::XS::true }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } elsif ($cmd eq "expunge") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | my $validity = same_validity ($args, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | if ($args->{uids}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | $imap->capability->{uidplus} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | or die "Server lacks UIDPLUS; refusing whole-mailbox fallback\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | checked ($imap->uidexpunge (uids ($args)), "UID EXPUNGE"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | checked ($imap->expunge, "EXPUNGE"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | return (1, { ok => JSON::XS::true, uidvalidity => $validity }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } elsif ($cmd eq "mailbox") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | my $op = $args->{operation}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | defined $op && $op =~ /\A(?:create|rename|delete|subscribe|unsubscribe)\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $op and $op =~ /\A(?:create|rename|delete|subscribe|unsubscribe)\z/u
MC/DC0%0/2
defined $op and $op =~ /\A(?:create|rename|delete|subscribe|unsubscribe)\z/u
defined $op
$op =~ /\A(?:create|rename|delete|subscribe|unsubscribe)\z/u
Truth table0%0/3
A and B
A= defined $opB= $op =~ /\A(?:create|rename|delete|subscribe|unsubscribe)\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | or die "Invalid mailbox operation\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | if ($op eq "delete" && !$args->{force}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$op eq "delete" and not $args->{"force"}
MC/DC0%0/2
$op eq "delete" and not $args->{"force"}
$op eq "delete"
not $args->{"force"}
Truth table0%0/3
A and not(B)
A= $op eq "delete"B= not $args->{"force"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | my $count = checked ($imap->status ($args->{mailbox}, "(MESSAGES)"), "STATUS")->{messages}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | defined $count && $count =~ /\A[0-9]+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $count and $count =~ /\A[0-9]+\z/u
MC/DC0%0/2
defined $count and $count =~ /\A[0-9]+\z/u
defined $count
$count =~ /\A[0-9]+\z/u
Truth table0%0/3
A and B
A= defined $countB= $count =~ /\A[0-9]+\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | or die "Server did not report mailbox message count\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | $count == 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | or die "Mailbox contains $count messages; use force to delete it\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | my @params = $op eq "rename" ? @{$args}{qw(mailbox destination)} : ($args->{mailbox}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | checked ($imap->$op (@params), uc $op); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | return (1, { ok => JSON::XS::true }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | die "Unknown IMAP operation\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | if (!$result && ($cmd eq "connect" || $cmd eq "ping" || !eval { $imap && $imap->is_open })) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/12
not $result and $cmd eq "connect" || $cmd eq "ping" || !eval {
do {
$imap and $imap->is_open
}
}
$cmd eq "connect" or $cmd eq "ping" or not eval {
do {
$imap and $imap->is_open
}
}
$cmd eq "connect" or $cmd eq "ping"
$imap && $imap->is_open
MC/DC0%0/4
not $result and $cmd eq "connect" || $cmd eq "ping" || !eval {
do {
$imap and $imap->is_open
}
}
not $result
$cmd eq "connect"
$cmd eq "ping"
not eval {
do {
$imap and $imap->is_open
}
}
MC/DC0%0/2
$imap && $imap->is_open
$imap
$imap->is_open
Truth table0%0/5
not(A) and B or C or not(D)
A= not $resultB= $cmd eq "connect"C= $cmd eq "ping"D= not eval {
do {
$imap and $imap->is_open
}
}
Truth table0%0/3
A && B
A= $imapB= $imap->is_open
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | # do not let IMAPTalk's destructor issue a blocking LOGOUT on a dead socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | $imap->state (Mail::IMAPTalk::Unconnected) if $imap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | undef $imap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | $result ? (1, $result) : (0, $error || "IMAP operation failed\n", $imap ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||