« blib/lib/Mail/AuthenticationResults/Header/SubEntry.pm
↑ Summary
lib/Mail/AuthenticationResults/Header.pm »
| 1 | package Mail::AuthenticationResults::Token::Comment; | ||||||||||||||
| 2 | # ABSTRACT: Class for modelling AuthenticationResults Header parts detected as comments | ||||||||||||||
| 3 | |||||||||||||||
| 4 | 31 | require 5.008; | |||||||||||||
| 5 | 31 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 31 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 31 | our $VERSION = '2.20260216'; # VERSION | |||||||||||||
| 8 | 31 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | 31 | ▶ | use base 'Mail::AuthenticationResults::Token'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | |||||||||||||||
| 13 | 406 | ▶ | sub is { | ||||||||||||
|
Subroutine
is: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 14 | 406 | my ( $self ) = @_; | |||||||||||||
| 15 | 406 | return 'comment'; | |||||||||||||
| 16 | } | ||||||||||||||
| 17 | |||||||||||||||
| 18 | 77 | ▶ | sub parse { | ||||||||||||
|
Subroutine
parse: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||
| 19 | 77 | my ($self) = @_; | |||||||||||||
| 20 | |||||||||||||||
| 21 | 77 | my $header = $self->{ 'header' }; | |||||||||||||
| 22 | 77 | my $value = q{}; | |||||||||||||
| 23 | 77 | my $depth = 0; | |||||||||||||
| 24 | |||||||||||||||
| 25 | 77 | my $first = substr( $header,0,1 ); | |||||||||||||
| 26 | 77 | ▶ | if ( $first ne '(' ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 27 | 1 | croak 'Not a comment'; | |||||||||||||
| 28 | } | ||||||||||||||
| 29 | |||||||||||||||
| 30 | 76 | ▶ | while ( length $header > 0 ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 31 | 1720 | my $first = substr( $header,0,1 ); | |||||||||||||
| 32 | 1720 | $header = substr( $header,1 ); | |||||||||||||
| 33 | 1720 | $value .= $first; | |||||||||||||
| 34 | 1720 | ▶ | if ( $first eq '(' ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 35 | 77 | $depth++; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | elsif ( $first eq ')' ) { | ||||||||||||||
| 38 | 76 | $depth--; | |||||||||||||
| 39 | 76 | ▶ | last if $depth == 0; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | } | ||||||||||||||
| 41 | } | ||||||||||||||
| 42 | |||||||||||||||
| 43 | 76 | ▶ | if ( $depth != 0 ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 44 | 1 | croak 'Mismatched parens in comment'; | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | 75 | $value =~ s/^\(//; | |||||||||||||
| 48 | 75 | $value =~ s/\)$//; | |||||||||||||
| 49 | |||||||||||||||
| 50 | 75 | $self->{ 'value' } = $value; | |||||||||||||
| 51 | 75 | $self->{ 'header' } = $header; | |||||||||||||
| 52 | |||||||||||||||
| 53 | 75 | return; | |||||||||||||
| 54 | } | ||||||||||||||
| 55 | |||||||||||||||
| 56 | 31 | 1; | |||||||||||||
| 57 | |||||||||||||||
| 58 | __END__ | ||||||||||||||