line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::BIMI::App::Command::checkvmc; |
2
|
|
|
|
|
|
|
# ABSTRACT: Check an VMC for validation |
3
|
|
|
|
|
|
|
our $VERSION = '3.20210301'; # VERSION |
4
|
2
|
|
|
2
|
|
2006
|
use 5.20.0; |
|
2
|
|
|
|
|
176
|
|
5
|
2
|
|
|
2
|
|
45
|
BEGIN { $ENV{MAIL_BIMI_CACHE_DEFAULT_BACKEND} = 'Null' }; |
6
|
2
|
|
|
2
|
|
13
|
use Mail::BIMI::Prelude; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
16
|
|
7
|
2
|
|
|
2
|
|
551
|
use Mail::BIMI::App -command; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
8
|
2
|
|
|
2
|
|
582
|
use Mail::BIMI; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
39
|
|
9
|
2
|
|
|
2
|
|
130
|
use Mail::BIMI::Indicator; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
94
|
|
10
|
2
|
|
|
2
|
|
13
|
use Mail::BIMI::VMC; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
61
|
|
11
|
2
|
|
|
2
|
|
12
|
use Term::ANSIColor qw{ :constants }; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1587
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
0
|
1
|
|
sub description { 'Check a VMC from a given URI or File for validity' } |
15
|
0
|
|
|
0
|
1
|
|
sub usage_desc { "%c checksvg %o <URI>" } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub opt_spec { |
18
|
|
|
|
|
|
|
return ( |
19
|
0
|
|
|
0
|
1
|
|
[ 'profile=s', 'SVG Profile to validate against ('.join('|',@Mail::BIMI::Indicator::VALIDATOR_PROFILES).')' ], |
20
|
|
|
|
|
|
|
[ 'domain=s', 'Domain' ], |
21
|
|
|
|
|
|
|
[ 'selector=s', 'Selector' ], |
22
|
|
|
|
|
|
|
[ 'fromfile', 'Fetch from file instead of from URI' ], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
1
|
|
sub validate_args($self,$opt,$args) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
$self->usage_error('No URI specified') if !@$args; |
28
|
0
|
0
|
|
|
|
|
$self->usage_error('Multiple URIs specified') if scalar @$args > 1; |
29
|
0
|
0
|
0
|
|
|
|
$self->usage_error('Unknown SVG Profile') if $opt->profile && !grep {;$_ eq $opt->profile} @Mail::BIMI::Indicator::VALIDATOR_PROFILES; |
|
0
|
|
|
|
|
|
|
30
|
0
|
0
|
0
|
|
|
|
$self->usage_error('Selector requires domain') if $opt->selector && !$opt->domain; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
sub execute($self,$opt,$args) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $uri = $args->[0]; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my %bimi_opt; |
37
|
0
|
0
|
|
|
|
|
if ( $opt->domain ) { |
38
|
0
|
|
|
|
|
|
$bimi_opt{domain} = $opt->domain; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
0
|
|
|
|
|
|
$bimi_opt{domain} = 'example.com'; |
42
|
|
|
|
|
|
|
} |
43
|
0
|
|
|
|
|
|
$bimi_opt{options} = {}; |
44
|
0
|
0
|
|
|
|
|
$bimi_opt{options}->{vmc_no_check_alt} = 1 if !$opt->domain; |
45
|
0
|
0
|
|
|
|
|
$bimi_opt{options}->{vmc_from_file} = $uri if $opt->fromfile; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $bimi = Mail::BIMI->new(%bimi_opt); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
0
|
|
|
|
my $vmc = Mail::BIMI::VMC->new( check_domain => $opt->domain//'', check_selector => $opt->selector//'default', uri => $uri, bimi_object => $bimi ); |
|
|
|
0
|
|
|
|
|
50
|
|
|
|
|
|
|
# $indicator->validator_profile($opt->profile) if $opt->profile; |
51
|
0
|
|
|
|
|
|
say "BIMI VMC checker"; |
52
|
0
|
|
|
|
|
|
say ''; |
53
|
0
|
|
|
|
|
|
say 'Requested:'; |
54
|
0
|
0
|
|
|
|
|
say YELLOW.($opt->fromfile?'File':'URI').WHITE.': '.$uri.RESET; |
55
|
0
|
|
|
|
|
|
say ''; |
56
|
0
|
|
|
|
|
|
$vmc->app_validate; |
57
|
0
|
|
|
|
|
|
say ''; |
58
|
0
|
0
|
|
|
|
|
if ( $vmc->indicator ) { |
59
|
0
|
|
|
|
|
|
$vmc->indicator->app_validate; |
60
|
0
|
|
|
|
|
|
say ''; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$bimi->finish; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=encoding UTF-8 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Mail::BIMI::App::Command::checkvmc - Check an VMC for validation |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 VERSION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
version 3.20210301 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
App::Cmd class implementing the 'mailbimi checkvmc' command |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 REQUIRES |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over 4 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * L<Mail::BIMI|Mail::BIMI> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * L<Mail::BIMI::App|Mail::BIMI::App> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Indicator|Mail::BIMI::Indicator> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * L<Mail::BIMI::VMC|Mail::BIMI::VMC> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * L<Term::ANSIColor|Term::ANSIColor> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=back |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Marc Bradshaw <marc@marcbradshaw.net> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Marc Bradshaw. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
113
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |