File Coverage

blib/lib/Mail/Message/Field/DKIM.pm
Criterion Covered Total %
statement 42 46 91.3
branch 1 2 50.0
condition n/a
subroutine 22 25 88.0
pod 19 20 95.0
total 84 93 90.3


line stmt bran cond sub pod time code
1             # This code is part of Perl distribution Mail-Message version 4.04.
2             # The POD got stripped from this file by OODoc version 3.06.
3             # For contributors see file ChangeLog.
4              
5             # This software is copyright (c) 2001-2026 by Mark Overmeer.
6              
7             # This is free software; you can redistribute it and/or modify it under
8             # the same terms as the Perl 5 programming language system itself.
9             # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10              
11              
12             package Mail::Message::Field::DKIM;{
13             our $VERSION = '4.04';
14             }
15              
16 28     28   1111 use parent 'Mail::Message::Field::Structured';
  28         62  
  28         230  
17              
18 28     28   2570 use warnings;
  28         61  
  28         1738  
19 28     28   172 use strict;
  28         66  
  28         1050  
20              
21 28     28   143 use Log::Report 'mail-message', import => [ qw/__x error/ ];
  28         57  
  28         218  
22              
23 28     28   5890 use URI ();
  28         9216  
  28         26427  
24              
25             #--------------------
26              
27             sub init($)
28 1     1 0 3 { my ($self, $args) = @_;
29 1         102 $self->{MMFD_tags} = +{ v => 1, a => 'rsa-sha256' };
30 1         11 $self->SUPER::init($args);
31             }
32              
33             sub parse($)
34 1     1 1 3 { my ($self, $string) = @_;
35 1         4 my $tags = $self->{MMFD_tags};
36              
37 1         11 foreach (split /\;/, $string)
38 13 50       102 { m/^\s*([a-z][a-z0-9_]*)\s*\=\s*([\s\x21-\x7E]+?)\s*$/is or next;
39             # tag-values stay unparsed (for now)
40 13         37 $self->addTag($1, $2);
41             }
42              
43 1         15 (undef, $string) = $self->consumeComment($string);
44 1         4 $self;
45             }
46              
47             sub produceBody()
48 0     0 1 0 { my $self = shift;
49             }
50              
51             #--------------------
52              
53              
54             sub addAttribute($;@)
55 0     0 1 0 { my $self = shift;
56 0         0 error __x"no attributes for DKIM headers.";
57             }
58              
59              
60             sub addTag($$)
61 13     13 1 33 { my ($self, $name) = (shift, lc shift);
62 13         48 $self->{MMFD_tags}{$name} = join ' ', @_;
63 13         25 $self;
64             }
65              
66              
67 13     13 1 111 sub tag($) { $_[0]->{MMFD_tags}{lc $_[1]} }
68              
69             #--------------------
70              
71 1     1 1 6 sub tagAlgorithm() { $_[0]->tag('a') }
72 1     1 1 5 sub tagSignData() { $_[0]->tag('b') }
73 1     1 1 4 sub tagSignature() { $_[0]->tag('bh') }
74 1     1 1 4 sub tagC14N() { $_[0]->tag('c') }
75 1     1 1 5 sub tagDomain() { $_[0]->tag('d') }
76 1     1 1 5 sub tagSignedHeaders() { $_[0]->tag('h') }
77 1     1 1 5 sub tagAgentID() { $_[0]->tag('i') }
78 0     0 1 0 sub tagBodyLength(){ $_[0]->tag('l') }
79 1     1 1 6 sub tagQueryMethods() { $_[0]->tag('q') }
80 1     1 1 5 sub tagSelector() { $_[0]->tag('s') }
81 1     1 1 5 sub tagTimestamp() { $_[0]->tag('t') }
82 1     1 1 4 sub tagExpires() { $_[0]->tag('x') }
83 1     1 1 1667 sub tagVersion() { $_[0]->tag('v') }
84 1     1 1 5 sub tagExtract() { $_[0]->tag('z') }
85              
86             #--------------------
87              
88             1;