| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Mail::DKIM::Canonicalization::Base; | 
| 2 | 14 |  |  | 14 |  | 112 | use strict; | 
|  | 14 |  |  |  |  | 34 |  | 
|  | 14 |  |  |  |  | 385 |  | 
| 3 | 14 |  |  | 14 |  | 71 | use warnings; | 
|  | 14 |  |  |  |  | 33 |  | 
|  | 14 |  |  |  |  | 562 |  | 
| 4 |  |  |  |  |  |  | our $VERSION = '1.20230212'; # VERSION | 
| 5 |  |  |  |  |  |  | # ABSTRACT: base class for canonicalization methods | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | # Copyright 2005-2007 Messiah College. All rights reserved. | 
| 8 |  |  |  |  |  |  | # Jason Long | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | # Copyright (c) 2004 Anthony D. Urso. All rights reserved. | 
| 11 |  |  |  |  |  |  | # This program is free software; you can redistribute it and/or | 
| 12 |  |  |  |  |  |  | # modify it under the same terms as Perl itself. | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 14 |  |  | 14 |  | 76 | use base 'Mail::DKIM::MessageParser'; | 
|  | 14 |  |  |  |  | 29 |  | 
|  | 14 |  |  |  |  | 6546 |  | 
| 15 | 14 |  |  | 14 |  | 154 | use Carp; | 
|  | 14 |  |  |  |  | 40 |  | 
|  | 14 |  |  |  |  | 5183 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub new { | 
| 18 | 926 |  |  | 926 | 0 | 2642 | my $class = shift; | 
| 19 | 926 |  |  |  |  | 2367 | return $class->new_object(@_); | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | sub init { | 
| 23 | 926 |  |  | 926 | 0 | 1323 | my $self = shift; | 
| 24 | 926 |  |  |  |  | 2263 | $self->SUPER::init; | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 926 | 50 | 33 |  |  | 5075 | unless ( $self->{output} | 
|  |  |  | 66 |  |  |  |  | 
|  |  |  | 66 |  |  |  |  | 
| 27 |  |  |  |  |  |  | || $self->{output_fh} | 
| 28 |  |  |  |  |  |  | || $self->{output_digest} | 
| 29 |  |  |  |  |  |  | || $self->{buffer} ) | 
| 30 |  |  |  |  |  |  | { | 
| 31 | 1 |  |  |  |  | 7 | $self->{result} = ''; | 
| 32 | 1 |  |  |  |  | 12 | $self->{buffer} = \$self->{result}; | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | sub output { | 
| 37 | 2707 |  |  | 2707 | 1 | 4222 | my $self = shift; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | # my ($output) = @_;  # optimized away for speed | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 2707 |  |  |  |  | 4359 | my $out_fh = $self->{output_fh}; | 
| 42 | 2707 | 50 |  |  |  | 5195 | if ($out_fh) { | 
| 43 | 0 |  |  |  |  | 0 | print $out_fh @_; | 
| 44 |  |  |  |  |  |  | } | 
| 45 | 2707 | 100 |  |  |  | 5711 | if ( my $digest = $self->{output_digest} ) { | 
| 46 | 2701 |  |  |  |  | 11603 | $digest->add(@_); | 
| 47 |  |  |  |  |  |  | } | 
| 48 | 2707 | 50 |  |  |  | 6506 | if ( my $out_obj = $self->{output} ) { | 
| 49 | 0 |  |  |  |  | 0 | $out_obj->PRINT(@_); | 
| 50 |  |  |  |  |  |  | } | 
| 51 | 2707 | 100 |  |  |  | 4925 | if ( my $buffer = $self->{buffer} ) { | 
| 52 | 6 |  |  |  |  | 16 | ${ $self->{buffer} } .= $_[0]; | 
|  | 6 |  |  |  |  | 29 |  | 
| 53 |  |  |  |  |  |  | } | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | # this supports Debug_Canonicalization | 
| 56 | 2707 | 50 |  |  |  | 7701 | if ( my $debug = $self->{Debug_Canonicalization} ) { | 
| 57 | 0 | 0 |  |  |  | 0 | if ( UNIVERSAL::isa( $debug, 'SCALAR' ) ) { | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
| 58 | 0 |  |  |  |  | 0 | $$debug .= $_[0]; | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  | elsif ( UNIVERSAL::isa( $debug, 'GLOB' ) ) { | 
| 61 | 0 |  |  |  |  | 0 | print $debug @_; | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  | elsif ( UNIVERSAL::isa( $debug, 'IO::Handle' ) ) { | 
| 64 | 0 |  |  |  |  | 0 | $debug->print(@_); | 
| 65 |  |  |  |  |  |  | } | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | sub result { | 
| 70 | 1 |  |  | 1 | 1 | 462 | my $self = shift; | 
| 71 | 1 |  |  |  |  | 5 | return $self->{result}; | 
| 72 |  |  |  |  |  |  | } | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | 1; | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | __END__ |