« lib/Mail/AuthenticationResults/Header/Group.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 | 32 | require 5.008; | |||||||||
| 5 | 32 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 32 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 32 | our $VERSION = '2.20261029'; # VERSION | |||||||||
| 8 | 32 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 32 | ▶ | use base 'Mail::AuthenticationResults::Token'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 4405 | ▶ | sub is { | ||||||||
|
Subroutine
is: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | 4405 | my ( $self ) = @_; | |||||||||
| 15 | 4405 | return 'comment'; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 2743 | ▶ | sub parse { | ||||||||
|
Subroutine
parse: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||
| 19 | 2743 | my ($self) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 2743 | my $header = $self->{ 'header' }; | |||||||||
| 22 | 2743 | my $value = q{}; | |||||||||
| 23 | 2743 | my $depth = 0; | |||||||||
| 24 | |||||||||||
| 25 | 2743 | my $first = substr( $header,0,1 ); | |||||||||
| 26 | 2743 | ▶ | if ( $first ne '(' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 1 | croak 'Not a comment'; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 2742 | my $end; | |||||||||
| 31 | 2742 | ▶ | while ( $header =~ /([()])/g ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 5485 | ▶ | if ( $1 eq '(' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 2743 | $depth++; | |||||||||
| 34 | } | ||||||||||
| 35 | else { | ||||||||||
| 36 | 2742 | $depth--; | |||||||||
| 37 | 2742 | ▶ | if ( $depth == 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 2741 | $end = pos( $header ); | |||||||||
| 39 | 2741 | last; | |||||||||
| 40 | } | ||||||||||
| 41 | } | ||||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 2742 | ▶ | if ( $depth != 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 1 | croak 'Mismatched parens in comment'; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 2741 | $value = substr( $header, 1, $end - 2 ); | |||||||||
| 49 | 2741 | $header = substr( $header, $end ); | |||||||||
| 50 | |||||||||||
| 51 | 2741 | $self->{ 'value' } = $value; | |||||||||
| 52 | 2741 | $self->{ 'header' } = $header; | |||||||||
| 53 | |||||||||||
| 54 | 2741 | return; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 32 | 1; | |||||||||
| 58 | |||||||||||
| 59 | __END__ | ||||||||||