File Coverage

blib/lib/Email/Simple/Creator.pm
Criterion Covered Total %
statement 20 20 100.0
branch 6 6 100.0
condition 2 2 100.0
subroutine 7 7 100.0
pod n/a
total 35 35 100.0


line stmt bran cond sub pod time code
1 22     22   278 use v5.12.0;
  22         69  
2 22     22   115 use warnings;
  22         36  
  22         808  
3             package Email::Simple::Creator 2.218;
4             # ABSTRACT: private helper for building Email::Simple objects
5              
6 22     22   114 use Carp ();
  22         43  
  22         7200  
7              
8             sub _crlf {
9 64     64   216 "\x0d\x0a";
10             }
11              
12             sub _date_header {
13 10     10   1398 require Email::Date::Format;
14 10         11343 Email::Date::Format::email_date();
15             }
16              
17             our @CARP_NOT = qw(Email::Simple Email::MIME);
18              
19             sub _add_to_header {
20 25     25   49 my ($class, $header, $key, $value) = @_;
21 25   100     57 $value //= '';
22              
23 25 100       221 Carp::carp "Header name '$key' with wide characters" if $key =~ /[^\x00-\xFF]/;
24 25 100       283 Carp::carp "Value '$value' for '$key' header with wide characters" if $value =~ /[^\x00-\xFF]/;
25              
26 25 100       100 if ($value =~ s/[\x0a\x0b\x0c\x0d\x85\x{2028}\x{2029}]+/ /g) {
27 1         225 Carp::carp("replaced vertical whitespace in $key header with space; this will become fatal in a future version");
28             }
29              
30 25         134 $$header .= Email::Simple::Header->__fold_objless("$key: $value", 78, q{ }, $class->_crlf);
31             }
32              
33             sub _finalize_header {
34 13     13   25 my ($class, $header) = @_;
35 13         29 $$header .= $class->_crlf;
36             }
37              
38             1;
39              
40             __END__