| 1 | package AnyEvent::MCP::IMAP::Providers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use common::sense; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use HTTP::Tiny (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use JSON::XS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | my $oauth_source = "https://raw.githubusercontent.com/mozilla/releases-comm-central/master/mailnews/base/src/OAuth2Providers.sys.mjs"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | my $ispdb = "https://autoconfig.thunderbird.net/"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | sub read_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_file: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | open my $fh, "<:raw", $file or die "$file: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | <$fh> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub download { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
download: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my ($url) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my $res = HTTP::Tiny->new ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | timeout => 8, verify_SSL => 1, max_redirect => 0, max_size => 1_000_000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | )->get ($url); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | $res->{success} ? $res->{content} : undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | sub parse_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_index: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | my ($json) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my $domains = JSON::XS::decode_json ($json); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | ref $domains eq "ARRAY" or die "Invalid Thunderbird ISPDB index\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | [grep !ref && valid_domain ($_) && !/\.test\z/, @$domains] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
!ref($_) && valid_domain($_) && !/\.test\z/u
not ref $_ and valid_domain($_)
MC/DC33%1/3
!ref($_) && valid_domain($_) && !/\.test\z/u
not ref $_
valid_domain($_)
!/\.test\z/u
Truth table50%2/4
not(A) and B && not(C)
A= not ref $_B= valid_domain($_)C= !/\.test\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Only recognize Thunderbird's declarative literal data; never execute JavaScript. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 7 | ▶ | sub parse_oauth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_oauth: called CC=25 SCAR=36.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 7 | my ($source) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 7 | my %scopes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 7 | ▶ | while ($source =~ /^const\s+([A-Z_]+_SCOPES)\s*=\s*(\{.*?^\};|"[^"]*";)/msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | my ($name, $value) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | ▶ | if ($value =~ /^\{/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | my %scope = $value =~ /\b(imap|extra)\s*:\s*"([^"]*)"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | $scopes{$name} = \%scope; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ($scopes{$name}) = $value =~ /^"([^"]*)"/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | ▶ | my ($hostnames) = $source =~ /\bvar\s+kHostnames\s*=\s*new Map\(\[\s*(.*?)^\]\);/ms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | or die "Thunderbird kHostnames layout changed\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | ▶ | my ($issuers) = $source =~ /\bvar\s+kIssuers\s*=\s*new Map\(\[\s*(.*?)^\]\);/ms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | or die "Thunderbird kIssuers layout changed\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | my %issuer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | while ($issuers =~ /\[\s*"([^"]+)"\s*,\s*\{\s*(.*?)^\s*\},?\s*\]/msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | my ($name, $fields) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | my %fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 5 | ▶ | while ($fields =~ /\b(clientId|clientSecret|authorizationEndpoint|tokenEndpoint|redirectionEndpoint|usePKCE)\s*:\s*(?:"([^"]*)"|\x60([^\x60]*)\x60|(true|false))/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 20 | ▶ | $fields{$1} = defined $2 ? $2 : defined $3 ? $3 : $4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 5 | $issuer{$name} = \%fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | ▶ | %issuer or die "Thunderbird kIssuers entries not recognized\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 5 | my %result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 5 | ▶ | while ($hostnames =~ /\[\s*"([^"]+)"\s*,\s*\[\s*"([^"]+)"\s*,\s*(?:"([^"]*)"|([A-Z_]+_SCOPES)(?:\.(\w+))?)\s*\]\s*\]/mg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 15 | my ($host, $name, $literal, $constant, $field) = ($1, $2, $3, $4, $5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 15 | ▶ | my $scope = defined $literal ? $literal : $scopes{$constant}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 15 | ▶ | $scope = $scope->{$field || "imap"} . (defined $scope->{extra} ? " $scope->{extra}" : "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%4/8
ref $scope eq "HASH" and !$field || $field eq "imap"
not $field or $field eq "imap"
$field || 'imap'
MC/DC33%1/3
ref $scope eq "HASH" and !$field || $field eq "imap"
ref $scope eq "HASH"
not $field
$field eq "imap"
MC/DC0%0/1
$field || 'imap'
$field
Truth table50%2/4
A and not(B) or C
A= ref $scope eq "HASH"B= not $fieldC= $field eq "imap"
Truth table50%1/2
A
A= $field
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | if ref $scope eq "HASH" && (!$field || $field eq "imap"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 15 | ▶ | next if ref $scope || !defined $scope || !length $scope; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $scope or not defined $scope or not length $scope
ref $scope or not defined $scope
MC/DC0%0/3
ref $scope or not defined $scope or not length $scope
ref $scope
not defined $scope
not length $scope
Truth table25%1/4
A or not(B) or not(C)
A= ref $scopeB= not defined $scopeC= not length $scope
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 15 | ▶ | my $data = $issuer{$name} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 15 | ▶ | $data->{clientId} && $data->{authorizationEndpoint} && $data->{tokenEndpoint} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$data->{"clientId"} and $data->{"authorizationEndpoint"} and $data->{"tokenEndpoint"}
$data->{"clientId"} and $data->{"authorizationEndpoint"}
MC/DC0%0/3
$data->{"clientId"} and $data->{"authorizationEndpoint"} and $data->{"tokenEndpoint"}
$data->{"clientId"}
$data->{"authorizationEndpoint"}
$data->{"tokenEndpoint"}
Truth table25%1/4
A and B and C
A= $data->{"clientId"}B= $data->{"authorizationEndpoint"}C= $data->{"tokenEndpoint"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 15 | $result{$host} = { %$data, issuer => $name, scope => $scope }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 5 | ▶ | %result or die "Thunderbird hostname/scope entries not recognized\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | \%result | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 6 | ▶ | sub parse_ispdb { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_ispdb: called CC=16 SCAR=28.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 6 | my ($xml, $email) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 6 | require XML::LibXML; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 6 | ▶ | length $xml <= 1_000_000 or die "Autoconfig XML too large\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 6 | my $doc = XML::LibXML->load_xml ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | string => $xml, no_network => 1, load_ext_dtd => 0, expand_entities => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 6 | ▶ | $doc->documentElement->nodeName eq "clientConfig" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | or die "Not a Thunderbird autoconfig document\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 6 | my @servers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 6 | for my $server ($doc->findnodes ("/clientConfig/emailProvider/incomingServer[\@type='imap']")) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 7 | my %info = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | server => $server->findvalue ("./hostname"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | port => $server->findvalue ("./port"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | tls => $server->findvalue ("./socketType"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | user => $server->findvalue ("./username"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 7 | my @auth = map $_->textContent, $server->findnodes ("./authentication"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 7 | my @methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 7 | ▶ | push @methods, "oauth2" if grep $_ eq "OAuth2", @auth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 7 | ▶ | push @methods, "password" if grep $_ eq "password-cleartext", @auth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 7 | ▶ | next unless @methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 7 | ▶ | $info{tls} = $info{tls} eq "SSL" ? "ssl" : $info{tls} eq "STARTTLS" ? "starttls" : next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 7 | ▶ | $info{port} =~ /^\d+$/ && $info{port} >= 1 && $info{port} <= 65535 or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$info{"port"} =~ /^\d+$/u and $info{"port"} >= 1 and $info{"port"} <= 65535
$info{"port"} =~ /^\d+$/u and $info{"port"} >= 1
MC/DC0%0/3
$info{"port"} =~ /^\d+$/u and $info{"port"} >= 1 and $info{"port"} <= 65535
$info{"port"} =~ /^\d+$/u
$info{"port"} >= 1
$info{"port"} <= 65535
Truth table25%1/4
A and B and C
A= $info{"port"} =~ /^\d+$/uB= $info{"port"} >= 1C= $info{"port"} <= 65535
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | ▶ | if (defined $email) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | my ($local, $domain) = split /\@/, $email, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 5 | for my $key (qw(server user)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 10 | $info{$key} =~ s/%EMAILADDRESS%/$email/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | $info{$key} =~ s/%EMAILLOCALPART%/$local/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 10 | $info{$key} =~ s/%EMAILDOMAIN%/$domain/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 7 | ▶ | delete $info{user} if $info{user} =~ /%/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 7 | ▶ | next if $info{server} !~ /\A[A-Za-z0-9.-]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 5 | $info{methods} = \@methods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | push @servers, \%info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 6 | name => scalar $doc->findvalue ("/clientConfig/emailProvider/displayName"), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | servers => \@servers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | notes => [map $_->textContent, $doc->findnodes ("/clientConfig/emailProvider/enable/instruction[not(\@lang)]")], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | links => [map $_->getAttribute ("visiturl"), $doc->findnodes ("/clientConfig/emailProvider/enable[\@visiturl]")], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 7 | ▶ | sub valid_domain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valid_domain: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 7 | $_[0] =~ /\A(?=.{1,253}\z)[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+\z/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | ▶ | sub find_oauth { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_oauth: called CC=6 SCAR=24.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | my ($all, @hosts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | for my $host (@hosts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | ▶ | next unless defined $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | ▶ | return $all->{$host} if $all->{$host}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | for my $name (keys %$all) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | return $all->{$name} if $host eq "imap.$name"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 21 | ▶ | sub quote { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 21 | my ($s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 21 | ▶ | return $s if $s =~ /\A[-A-Za-z0-9_@%+=:,\.\/]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 4 | $s =~ s/'/'\\''/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | "'$s'" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | ▶ | sub print_login { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_login: called CC=12 SCAR=25.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | my ($name, $server, $method, $oauth) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | my @kv = (method => $method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | for my $key (qw(server tls port user)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 8 | ▶ | push @kv, $key => $server->{$key} if defined $server->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | ▶ | if ($method eq "oauth2") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | push @kv, "oauth-client-id" => $oauth->{clientId}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | ▶ | push @kv, "oauth-client-secret" => $oauth->{clientSecret} if defined $oauth->{clientSecret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | push @kv, "oauth-authorization-endpoint" => $oauth->{authorizationEndpoint}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | push @kv, "oauth-token-endpoint" => $oauth->{tokenEndpoint}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | push @kv, "oauth-scope" => $oauth->{scope}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | ▶ | push @kv, "oauth-pkce" => $oauth->{usePKCE} && $oauth->{usePKCE} eq "true" ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$oauth->{"usePKCE"} and $oauth->{"usePKCE"} eq "true"
MC/DC0%0/2
$oauth->{"usePKCE"} and $oauth->{"usePKCE"} eq "true"
$oauth->{"usePKCE"}
$oauth->{"usePKCE"} eq "true"
Truth table33%1/3
A and B
A= $oauth->{"usePKCE"}B= $oauth->{"usePKCE"} eq "true"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | my $redirect = $oauth->{redirectionEndpoint} || "http://127.0.0.1"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$oauth->{'redirectionEndpoint'} || 'http://127.0.0.1'
MC/DC0%0/1
$oauth->{'redirectionEndpoint'} || 'http://127.0.0.1'
$oauth->{'redirectionEndpoint'}
Truth table50%1/2
A
A= $oauth->{'redirectionEndpoint'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | $redirect .= ":1" if $redirect =~ m{\Ahttp://(?:127\.0\.0\.1|localhost)\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | push @kv, "oauth-redirect-uri" => $redirect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | ▶ | print "mcp-imap --name ", quote ($name), " login", @kv ? " \\\n" : "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | ▶ | while (@kv) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 16 | my ($key, $value) = splice @kv, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 16 | ▶ | print " $key ", quote ($value), @kv ? " \\\n" : "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=46 SCAR=46.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | my ($name, $provider_file, $ispdb_file, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | ▶ | @args <= 1 or die "Usage: mcp-imap [OPTION]... providers [SEARCH]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | my $search = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 3 | my $email; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | ▶ | if (defined $search && $search =~ /\A([^\s\@]+)\@([A-Za-z0-9.-]+)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $search and $search =~ /\A([^\s\@]+)\@([A-Za-z0-9.-]+)\z/u
MC/DC100%2/2
defined $search and $search =~ /\A([^\s\@]+)\@([A-Za-z0-9.-]+)\z/u
defined $search
$search =~ /\A([^\s\@]+)\@([A-Za-z0-9.-]+)\z/u
Truth table100%3/3
A and B
A= defined $searchB= $search =~ /\A([^\s\@]+)\@([A-Za-z0-9.-]+)\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | $email = $search; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | $search = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 3 | ▶ | my $source = defined $provider_file ? read_file ($provider_file) : download ($oauth_source); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | ▶ | my $oauth = defined $source ? parse_oauth ($source) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | ▶ | my $index = defined $provider_file || defined $ispdb_file ? [] : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
defined $provider_file or defined $ispdb_file
download($ispdb . 'generated_files.json') || '[]'
MC/DC0%0/2
defined $provider_file or defined $ispdb_file
defined $provider_file
defined $ispdb_file
MC/DC0%0/1
download($ispdb . 'generated_files.json') || '[]'
download($ispdb . 'generated_files.json')
Truth table33%1/3
A or B
A= defined $provider_fileB= defined $ispdb_file
Truth table0%0/2
A
A= download($ispdb . 'generated_files.json')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | parse_index (download ($ispdb . "generated_files.json") || "[]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | my %known = map +($_ => 1), (@$index, keys %$oauth); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | delete @known{grep /^(?:smtp|pop|pop3|carddav|carddav-personal|caldav|graph|www\.googleapis|apidata)\.|\.test\z/, keys %known}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | my @domains = sort grep !defined $search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | || index (lc $_, lc $search) >= 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 3 | ▶ | || ($oauth->{$_} && index (lc $oauth->{$_}{issuer}, lc $search) >= 0), keys %known; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%6/9
!defined($search) || index(lc $_, lc $search) != -1 || $oauth->{$_} && index(lc $oauth->{$_}{'issuer'}, lc $search) != -1
not defined $search or index(lc $_, lc $search) != -1
$oauth->{$_} and index(lc $oauth->{$_}{"issuer"}, lc $search) != -1
MC/DC0%0/4
!defined($search) || index(lc $_, lc $search) != -1 || $oauth->{$_} && index(lc $oauth->{$_}{'issuer'}, lc $search) != -1
not defined $search
index(lc $_, lc $search) != -1
$oauth->{$_}
index(lc $oauth->{$_}{"issuer"}, lc $search) != -1
Truth table60%3/5
not(A) or B || C and D
A= not defined $searchB= index(lc $_, lc $search) != -1C= $oauth->{$_}D= index(lc $oauth->{$_}{"issuer"}, lc $search) != -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | ▶ | my @exact = defined $search ? grep lc $_ eq lc $search, @domains : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | ▶ | @domains = @exact if @exact; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | ▶ | if (!defined $search || @domains > 1 || !@domains && !valid_domain ($search)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
not defined $search or @domains > 1 or not @domains || valid_domain($search)
not defined $search or @domains > 1
@domains || valid_domain($search)
MC/DC50%2/4
not defined $search or @domains > 1 or not @domains || valid_domain($search)
not defined $search
@domains > 1
@domains
valid_domain($search)
Truth table60%3/5
not(A) or B or not(C || D)
A= not defined $searchB= @domains > 1C= @domainsD= valid_domain($search)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | ▶ | @domains or die "No matching providers\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | print "Thunderbird mail providers (", scalar @domains, " matches):\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | printf " %-32s %s\n", $_, $oauth->{$_} ? "OAuth: $oauth->{$_}{issuer}" : "ISPDB" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | for @domains; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | print "\nSpecify a domain or email address to generate login commands.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | my $domain = @domains == 1 ? $domains[0] : $search; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | valid_domain ($domain) or die "Invalid provider domain\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | my ($xml, $origin); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | if (defined $ispdb_file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | $xml = read_file ($ispdb_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | $origin = "local XML ($ispdb_file)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | for my $url ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | "https://autoconfig.$domain/mail/config-v1.1.xml", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | "https://$domain/.well-known/autoconfig/mail/config-v1.1.xml", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | $ispdb . "v1.1/$domain", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $xml = download ($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | if (defined $xml) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $origin = $url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | ▶ | my $config = defined $xml ? parse_ispdb ($xml, $email) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | { name => "", servers => [], notes => [], links => [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | ▶ | print "Provider: $domain", $config->{name} ? " ($config->{name})" : "", "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | ▶ | print "IMAP configuration: ", $origin || "not found", "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$origin || 'not found'
MC/DC0%0/1
$origin || 'not found'
$origin
Truth table50%1/2
A
A= $origin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | print "OAuth reference: $oauth_source\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | ▶ | if find_oauth ($oauth, $domain, map $_->{server}, @{$config->{servers}}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | print "No IMAP autoconfiguration found; server, TLS and port require manual setup.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | unless @{$config->{servers}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | print "Setup: $_\n" for grep length, @{$config->{notes}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | print "Setup URL: $_\n" for grep length, @{$config->{links}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | my @servers = @{$config->{servers}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | ▶ | push @servers, { server => $domain =~ /^imap\./ ? $domain : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not @servers and find_oauth($oauth, $domain)
MC/DC0%0/2
not @servers and find_oauth($oauth, $domain)
not @servers
find_oauth($oauth, $domain)
Truth table33%1/3
not(A) and B
A= not @serversB= find_oauth($oauth, $domain)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | methods => ["oauth2"] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | if !@servers && find_oauth ($oauth, $domain); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | ▶ | @servers or die "No supported IMAP configuration for $domain\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | for my $server (@servers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | my $o = find_oauth ($oauth, $domain, $server->{server}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | print "\nIMAP $server->{server}:$server->{port} ($server->{tls}), authentication: ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | join (", ", @{$server->{methods}}), "\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | ▶ | if defined $server->{server} && defined $server->{port}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $server->{"server"} and defined $server->{"port"}
MC/DC0%0/2
defined $server->{"server"} and defined $server->{"port"}
defined $server->{"server"}
defined $server->{"port"}
Truth table33%1/3
A and B
A= defined $server->{"server"}B= defined $server->{"port"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | for my $method (@{$server->{methods}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | ▶ | if ($method eq "oauth2" && !$o) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$method eq "oauth2" and not $o
MC/DC0%0/2
$method eq "oauth2" and not $o
$method eq "oauth2"
not $o
Truth table66%2/3
A and not(B)
A= $method eq "oauth2"B= not $o
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | print "OAuth2 advertised, but no usable Thunderbird client registration was found.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | ▶ | print "\n# ", $method eq "oauth2" ? "OAuth2" : "Password", ":\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 2 | ▶ | print "# Thunderbird's OAuth client registration may not be authorized for other applications.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | if $method eq "oauth2"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | ▶ | print "# OAuth2 requires a refresh token; provider-specific offline access parameters may be needed.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | if $method eq "oauth2"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | print_login ($name, $server, $method, $o); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||