Box/Parser.pm

filter: Statementstmt 76.2% 45 / 59 Branchbran 56.2% 9 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.8% 14 / 23 Podpod 94.7% 18 / 19 totaltotal 73.5% 86 / 117 CC 9 SCAR 9.4
CC
9
Cov
72%
fixHeaderErrors
6.0
defaultParserType
5.9
pushSeparator
2.0
CRAP 2.6
« Message/Body/String.pm ↑ Summary Message/Convert/MimeEntity.pm »
1 # This code is part of Perl distribution Mail-Message version 4.05.
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::Box::Parser;{
13 41 our $VERSION = '4.05';
14 }
15  
16 41 ▶use parent 'Mail::Reporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 41 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 41 ▶use Log::Report 'mail-message', import => [ qw/__x error/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 #--------------------
24  
25 sub new(@)
26 20 ▶{ my $class = shift;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
27  
28 20 ▶ $class eq __PACKAGE__
Branch: 1 branch
BranchTrueFalseTotal
$class eq __PACKAGE__ ? : 2 18 20
29 ? $class->defaultParserType->new(@_) # bootstrap right parser
30 : $class->SUPER::new(@_);
31 }
32  
33 sub init(@)
34 18 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
35 18 $self->SUPER::init($args);
36  
37 18 $self->{MBP_trusted} = $args->{trusted};
38 18 $self->{MBP_fix} = $args->{fix_header_errors};
39 18 $self->{MBP_seps} = [];
40 18 $self;
41 }
42  
43 #--------------------
44  
45 sub fixHeaderErrors(;$)
46 0 ▶{ my $self = shift;
Subroutine fixHeaderErrors: not called CC=2 SCAR=17.9
Pod documented
47 0 ▶ @_ ? ($self->{MBP_fix} = shift) : $self->{MBP_fix};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
48 }
49  
50  
51 45 ▶sub trusted() { $_[0]->{MBP_trusted} }
Subroutine trusted: called CC=1 SCAR=0.0
Pod documented
52  
53  
54 41 my $parser_type;
55  
56 sub defaultParserType(;$)
57 3 ▶{ my $class = shift;
Subroutine defaultParserType: called CC=5 SCAR=17.8
Pod documented
58  
59 # Select the parser manually?
60 3 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 2 3
61 1 { $parser_type = shift;
62 1 ▶ return $parser_type if $parser_type->isa( __PACKAGE__ );
Branch: 1 branch
BranchTrueFalseTotal
if $parser_type->isa(__PACKAGE__) 1 0 1
63 0 error __x"parser {type} does not extend {pkg}.", type => $parser_type, pkg => __PACKAGE__;
64 }
65  
66 # Already determined which parser we want?
67 $parser_type
68 2 ▶ and return $parser_type;
Branch: 1 branch
BranchTrueFalseTotal
$parser_type and return $parser_type 0 2 2
69  
70 # Try to use C-based parser.
71 2 eval 'require Mail::Box::Parser::C';
72 2 ▶ $@ or return $parser_type = 'Mail::Box::Parser::C';
Branch: 1 branch
BranchTrueFalseTotal
$@ or return $parser_type = "Mail::Box::Parser::C" 0 2 2
73  
74 # Fall-back on Perl-based parser.
75 0 require Mail::Box::Parser::Perl;
76 0 $parser_type = 'Mail::Box::Parser::Perl';
77 }
78  
79 #--------------------
80  
81 0 ▶sub readHeader() { $_[0]->notImplemented }
Subroutine readHeader: not called CC=1 SCAR=6.9
Pod documented
82  
83  
84 0 ▶sub bodyAsString() { $_[0]->notImplemented }
Subroutine bodyAsString: not called CC=1 SCAR=6.9
Pod documented
85  
86  
87 0 ▶sub bodyAsList() { $_[0]->notImplemented }
Subroutine bodyAsList: not called CC=1 SCAR=6.9
Pod documented
88  
89  
90 0 ▶sub bodyAsFile() { $_[0]->notImplemented }
Subroutine bodyAsFile: not called CC=1 SCAR=6.9
Pod documented
91  
92  
93 0 ▶sub bodyDelayed() { $_[0]->notImplemented }
Subroutine bodyDelayed: not called CC=1 SCAR=6.9
Pod documented
94  
95  
96 0 ▶sub lineSeparator() { $_[0]->{MBP_linesep} }
Subroutine lineSeparator: not called CC=1 SCAR=6.9
Pod documented
97  
98  
99 16 ▶sub stop() { }
Subroutine stop: called CC=1 SCAR=0.0
Pod documented
100 sub filePosition() { undef }
101  
102 #--------------------
103  
104 0 ▶sub readSeparator() { $_[0]->notImplemented }
Subroutine readSeparator: not called CC=1 SCAR=6.9
Pod documented
105  
106  
107 sub pushSeparator($)
108 10 ▶{ my ($self, $sep) = @_;
Subroutine pushSeparator: called CC=2 SCAR=7.0
Pod documented
109 10 unshift @{$self->{MBP_seps}}, $sep;
110 10 ▶ $self->{MBP_strip_gt}++ if $sep eq 'From ';
Branch: 1 branch
BranchTrueFalseTotal
if $sep eq "From " 0 10 10
111 10 $self;
112 }
113  
114  
115 sub popSeparator()
116 10 ▶{ my $self = shift;
Subroutine popSeparator: called CC=2 SCAR=7.0
Pod documented
117 10 my $sep = shift @{$self->{MBP_seps}};
118 10 ▶ $self->{MBP_strip_gt}-- if $sep eq 'From ';
Branch: 1 branch
BranchTrueFalseTotal
if $sep eq "From " 0 10 10
119 10 $sep;
120 }
121  
122  
123 74 ▶sub separators() { $_[0]->{MBP_seps} }
Subroutine separators: called CC=1 SCAR=0.0
Pod documented
124 29 ▶sub activeSeparator() { $_[0]->separators->[0] }
Subroutine activeSeparator: called CC=1 SCAR=0.0
Pod documented
125 0 ▶sub resetSeparators() { $_[0]->{MBP_seps} = []; $_[0]->{MBP_strip_gt} = 0 }
Subroutine resetSeparators: not called CC=1 SCAR=6.9
Pod documented
126 45 ▶sub stripGt { $_[0]->{MBP_strip_gt} }
Subroutine stripGt: called CC=1 SCAR=0.0
Pod documented
127  
128 #--------------------
129  
130 #--------------------
131  
132 41 1;
« Message/Body/String.pm ↑ Summary Message/Convert/MimeEntity.pm »