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