| 1 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # Explode.pm | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Last Modification: Sun Jun 26 21:19:40 WEST 2011 | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # Copyright (c) 2011 Henrique Dias <henrique.ribeiro.dias@gmail.com>. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # This module is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | package MIME::Explode; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | require DynaLoader; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | require AutoLoader; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use SelfLoader; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | @ISA = qw(Exporter DynaLoader); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | @EXPORT = qw(&rfc822_base64 &rfc822_qprint); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | $VERSION = '0.39'; | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use constant BUFFSIZE => 64; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | my %h_hash = ( | |||||||||||||||||||||||||||||||||||||||||
| 29 | 'content-type' => "", | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 'content-disposition' => "", | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 'content-transfer-encoding' => "", | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | my @patterns = ( | |||||||||||||||||||||||||||||||||||||||||
| 35 | '^([^= ]+) *=[ \"]*([^\"]+)', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | '^(\w[\w\-\.]*):[\x20\x09]*([^\x0d\x0a\f]*)[\x0d\x0a\f]+', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | '^[\x0a\x0d]+$', | ||||||||||||||||||||||||||||||||||||||||||
| 38 | '^begin\s*(\d\d\d)\s*(\S+)', | ||||||||||||||||||||||||||||||||||||||||||
| 39 | '^From +[^ ]+ +[a-zA-Z]{3} [a-zA-Z]{3} [ \d]\d \d\d:\d\d:\d\d \d{4}( [\+\-]\d\d\d\d)?[\x0a\x0d]+', | ||||||||||||||||||||||||||||||||||||||||||
| 40 | '^[\x20\x09]+(?=.*[^\x0a\x0d]+)', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | '^[\x20\x09]+\w+\=[^\=]+' | ||||||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | my %content_type = ( | |||||||||||||||||||||||||||||||||||||||||
| 45 | "text/html" => ".html", | ||||||||||||||||||||||||||||||||||||||||||
| 46 | "text/plain" => ".txt", | ||||||||||||||||||||||||||||||||||||||||||
| 47 | "message/rfc822" => ".rfc822", | ||||||||||||||||||||||||||||||||||||||||||
| 48 | "text/richtext" => ".richtext", | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | SelfLoader->load_stubs(); | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 57 | output_dir => "/tmp", | ||||||||||||||||||||||||||||||||||||||||||
| 58 | mkdir => 0755, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | decode_subject => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | check_content_type => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | content_types => [], | ||||||||||||||||||||||||||||||||||||||||||
| 62 | types_action => "include", | ||||||||||||||||||||||||||||||||||||||||||
| 63 | @_, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $self->init(); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | return() if((-d $self->{'output_dir'}) || !$self->{'mkdir'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $self->{"output_dir"} or not $self->{"mkdir"}
MC/DC0%0/2
-d $self->{"output_dir"} or not $self->{"mkdir"}
-d $self->{"output_dir"}
not $self->{"mkdir"}
Truth table0%0/3
A or not(B)
A= -d $self->{"output_dir"}B= not $self->{"mkdir"}
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | mkdir($self->{'output_dir'}, $self->{'mkdir'}) or | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | die(join("", "MIME::Explode: Failed to create directory \"", $self->{'output_dir'}, "\": $!")); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub clean_all { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_all: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $dir = $self->{'output_dir'}; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | opendir(DIRECTORY, $dir) or return("Can't opendir \"$dir\": $!\n"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | while(defined(my $file = readdir(DIRECTORY))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | next if($file =~ /^\.\.?$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $path = "$dir/$file"; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if(my ($f) = ($path =~ /^(.+)$/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | unlink($f) or return("Couldn't unlink \"$f\" file: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | closedir(DIRECTORY); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | rmdir($dir) or return("Couldn't rmdir \"$dir\" directory: $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | local $/ = "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my %headers = (); | |||||||||||||||||||||||||||||||||||||||||
| 100 | my %args = ( | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 'output_dir' => $self->{'output_dir'}, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 'check_ctype' => $self->{'check_content_type'} || 0, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 'decode_subject' => $self->{'decode_subject'}, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 'ctypes' => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | 'types_action' => $self->{'types_action'} eq "include" ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{'check_content_type'} || 0
MC/DC0%0/1
$self->{'check_content_type'} || 0
$self->{'check_content_type'}
Truth table0%0/2
A
A= $self->{'check_content_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $self->{'content_types'} = $self->{'exclude_types'} if(exists($self->{'exclude_types'}) && scalar(@{$self->{'exclude_types'}})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
exists $self->{"exclude_types"} and scalar @{$self->{"exclude_types"};}
MC/DC0%0/1
exists $self->{"exclude_types"} and scalar @{$self->{"exclude_types"};}
exists $self->{"exclude_types"}
Truth table0%0/2
A
A= exists $self->{"exclude_types"}
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if(scalar(@{$self->{'content_types'}})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my %ctypes = (); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | @ctypes{@{$self->{'content_types'}}} = (0 .. $#{$self->{'content_types'}}); | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $args{'ctypes'} = \%ctypes; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $last = &_parse(\@_, 1, 0, "0", "", \%args, {}, \%headers); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $self->{nmsgs} = ($last->[0]) ? (split(/\./, $last->[0]))[0] + 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my ($fh_mail, $fh_tmp) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if(defined($fh_tmp)) { while(<$fh_mail>) { print $fh_tmp $_; } } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return(\%headers); | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub nmsgs { $_[0]->{'nmsgs'} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nmsgs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub _parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse: not called CC=111 SCAR=94.3
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $fhs = shift; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $header = shift; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | my $mbox = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my $base = shift || "0"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || '0'
MC/DC0%0/1
shift() || '0'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $origin = shift || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $files = shift; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my ($fh_mail, $fh_tmp) = @{$fhs}; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my ($tree, $key, $tmpbuff, $boundary, $ftmp) = (join("\.", $base, "0"), "", "", "", ""); | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my ($check_ctype, $ctlength) = (1, 0); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my ($ph, $tmp, $exclude, $attcount, $checkhdr) = (0, 0, 0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | while(local $_ = <$fh_mail>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | defined($fh_tmp) and print $fh_tmp $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if($header) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ($ph, $attcount, $exclude, $tmpbuff, $check_ctype, $ctlength, $ftmp) = (1, 0, 0, "", 1, 0, ""); | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if(!$mbox && $base eq "0" && /$patterns[4]/o) { $mbox = 1; next; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $mbox and $base eq 0 and /$patterns[4]/o
not $mbox and $base eq 0
MC/DC0%0/3
not $mbox and $base eq 0 and /$patterns[4]/o
not $mbox
$base eq 0
/$patterns[4]/o
Truth table0%0/4
not(A) and B and C
A= not $mboxB= $base eq 0C= /$patterns[4]/o
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if(exists($_[0]->{$tree}->{$key})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | s/\x0d//og; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if(s/$patterns[5]/ /o) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | s/\s+$//o; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if(ref($_[0]->{$tree}->{$key}) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $_[0]->{$tree}->{$key}->[$#{$_[0]->{$tree}->{$key}}] .= $_; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if(ref($_[0]->{$tree}->{$key}) eq "HASH") { $_[0]->{$tree}->{$key}->{value} .= $_; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | $key eq "subject" and $_[0]->{$tree}->{$key} =~ /\?\=$/o and s/^ (?=\=\?)//o; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key eq "subject" and $_[0]{$tree}{$key} =~ /\?\=$/o
MC/DC0%0/2
$key eq "subject" and $_[0]{$tree}{$key} =~ /\?\=$/o
$key eq "subject"
$_[0]{$tree}{$key} =~ /\?\=$/o
Truth table0%0/3
A and B
A= $key eq "subject"B= $_[0]{$tree}{$key} =~ /\?\=$/o
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $_[0]->{$tree}->{$key} .= $_; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if(exists($h_hash{$key}) && exists($_[0]->{$tree}->{$key}->{value})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
exists $h_hash{$key} and exists $_[0]{$tree}{$key}{"value"}
MC/DC0%0/2
exists $h_hash{$key} and exists $_[0]{$tree}{$key}{"value"}
exists $h_hash{$key}
exists $_[0]{$tree}{$key}{"value"}
Truth table0%0/3
A and B
A= exists $h_hash{$key}B= exists $_[0]{$tree}{$key}{"value"}
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | &header2hash($_[0]->{$tree}->{$key}, $_[0]->{$tree}->{$key}->{value}); | |||||||||||||||||||||||||||||||||||||||||
| 158 | ▶ | } elsif($key eq "subject" && $args->{decode_subject}) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$key eq "subject" and $args->{"decode_subject"}
MC/DC0%0/2
$key eq "subject" and $args->{"decode_subject"}
$key eq "subject"
$args->{"decode_subject"}
Truth table0%0/3
A and B
A= $key eq "subject"B= $args->{"decode_subject"}
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my @parts = &decode_mimewords($_[0]->{$tree}->{subject}); | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | delete($_[0]->{$tree}->{subject}); | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | $_[0]->{$tree}->{subject}->{value} = [map {$_->[0] || ""} @parts]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->[0] || ''
MC/DC0%0/1
$_->[0] || ''
$_->[0]
Truth table0%0/2
A
A= $_->[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | $_[0]->{$tree}->{subject}->{charset} = [map {$_->[1] || "us-ascii"} @parts]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->[1] || 'us-ascii'
MC/DC0%0/1
$_->[1] || 'us-ascii'
$_->[1]
Truth table0%0/2
A
A= $_->[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | } elsif(/$patterns[6]/o) { next; } | |||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if(/$patterns[1]/o) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | defined($fh) and &file_close($fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ($header, $checkhdr) = (1, 1); | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $key = lc($1); | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if($key eq "received" || $key eq "x-received") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key eq "received" or $key eq "x-received"
MC/DC0%0/2
$key eq "received" or $key eq "x-received"
$key eq "received"
$key eq "x-received"
Truth table0%0/3
A or B
A= $key eq "received"B= $key eq "x-received"
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | push(@{$_[0]->{$tree}->{$key}}, $2); | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | unless(exists($_[0]->{$tree}->{$key})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | $_[0]->{$tree}->{$key} = (exists($h_hash{$key})) ? {value => $2} : $2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | next if(!$checkhdr && (length() <= 2) && /$patterns[2]/o); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $checkhdr and length $_ <= 2 and /$patterns[2]/o
not $checkhdr and length $_ <= 2
MC/DC0%0/3
not $checkhdr and length $_ <= 2 and /$patterns[2]/o
not $checkhdr
length $_ <= 2
/$patterns[2]/o
Truth table0%0/4
not(A) and B and C
A= not $checkhdrB= length $_ <= 2C= /$patterns[2]/o
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $header = 0; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if(exists($_[0]->{$tree}->{'content-type'}) && exists($_[0]->{$tree}->{'content-type'}->{value})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $_[0]{$tree}{"content-type"} and exists $_[0]{$tree}{"content-type"}{"value"}
MC/DC0%0/2
exists $_[0]{$tree}{"content-type"} and exists $_[0]{$tree}{"content-type"}{"value"}
exists $_[0]{$tree}{"content-type"}
exists $_[0]{$tree}{"content-type"}{"value"}
Truth table0%0/3
A and B
A= exists $_[0]{$tree}{"content-type"}B= exists $_[0]{$tree}{"content-type"}{"value"}
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $_[0]->{$tree}->{'content-type'}->{value} = lc($_[0]->{$tree}->{'content-type'}->{value}); | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if(exists($_[0]->{$tree}->{'content-type'}->{boundary}) && $_[0]->{$tree}->{'content-type'}->{value} =~ /multipart\/\w+/o) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
exists $_[0]{$tree}{"content-type"}{"boundary"} and $_[0]{$tree}{"content-type"}{"value"} =~ m[multipart/\w+]o
MC/DC0%0/2
exists $_[0]{$tree}{"content-type"}{"boundary"} and $_[0]{$tree}{"content-type"}{"value"} =~ m[multipart/\w+]o
exists $_[0]{$tree}{"content-type"}{"boundary"}
$_[0]{$tree}{"content-type"}{"value"} =~ m[multipart/\w+]o
Truth table0%0/3
A and B
A= exists $_[0]{$tree}{"content-type"}{"boundary"}B= $_[0]{$tree}{"content-type"}{"value"} =~ m[multipart/\w+]o
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $res = &_parse($fhs, $header, $mbox, $tree, $_[0]->{$tree}->{'content-type'}->{boundary}, $args, $files, $_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if($res->[1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | $mbox ? ($tmp = 1) : return([$tree, $res->[1]]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $_ = $res->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | } else { next; } | |||||||||||||||||||||||||||||||||||||||||
| 189 | } elsif($_[0]->{$tree}->{'content-type'}->{value} eq "message/rfc822") { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $res = &_parse($fhs, 1, $mbox, $tree, $origin, $args, $files, $_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if($res->[1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | $mbox ? ($tmp = 1) : return([$tree, $res->[1]]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $_ = $res->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | } else { next; } | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $checkhdr = 0; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $key = ""; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | defined($_) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if(/$patterns[3]/o) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $file = &check_filename($files, $2); | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | my $filepath = ($args->{output_dir}) ? join("/", $args->{output_dir}, $file) : $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | my $res = uu_file($fhs, $filepath, $1 || "644", | ||||||||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||||||||
| 206 | action => $args->{'types_action'}, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | mimetypes => $args->{'ctypes'} | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$1 || '644'
MC/DC0%0/1
$1 || '644'
$1
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $_[0]->{"$tree.$attcount"}->{'content-type'}->{value} = $res->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $_[0]->{"$tree.$attcount"}->{'content-disposition'}->{filepath} = $filepath unless($res->[1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $attcount++; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $breakmsg = ""; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | unless(defined($fh)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $boundary = $origin; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if(exists($_[0]->{$tree}->{'content-type'}) && exists($_[0]->{$tree}->{'content-type'}->{value})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $_[0]{$tree}{"content-type"} and exists $_[0]{$tree}{"content-type"}{"value"}
MC/DC0%0/2
exists $_[0]{$tree}{"content-type"} and exists $_[0]{$tree}{"content-type"}{"value"}
exists $_[0]{$tree}{"content-type"}
exists $_[0]{$tree}{"content-type"}{"value"}
Truth table0%0/3
A and B
A= exists $_[0]{$tree}{"content-type"}B= exists $_[0]{$tree}{"content-type"}{"value"}
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $exclude = 1 if(($_[0]->{$tree}->{'content-type'}->{value} =~ /^multipart\/\w+$/o) || ($_[0]->{$tree}->{'content-type'}->{value} eq "message/rfc822")); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[0]{$tree}{"content-type"}{"value"} =~ m[^multipart/\w+$]o or $_[0]{$tree}{"content-type"}{"value"} eq "message/rfc822"
MC/DC0%0/2
$_[0]{$tree}{"content-type"}{"value"} =~ m[^multipart/\w+$]o or $_[0]{$tree}{"content-type"}{"value"} eq "message/rfc822"
$_[0]{$tree}{"content-type"}{"value"} =~ m[^multipart/\w+$]o
$_[0]{$tree}{"content-type"}{"value"} eq "message/rfc822"
Truth table0%0/3
A or B
A= $_[0]{$tree}{"content-type"}{"value"} =~ m[^multipart/\w+$]oB= $_[0]{$tree}{"content-type"}{"value"} eq "message/rfc822"
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | } else { $check_ctype = 1; } | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | unless($exclude) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if(exists($_[0]->{$tree}->{'content-transfer-encoding'}) && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $_[0]{$tree}{"content-transfer-encoding"} and exists $_[0]{$tree}{"content-transfer-encoding"}{"value"}
MC/DC0%0/2
exists $_[0]{$tree}{"content-transfer-encoding"} and exists $_[0]{$tree}{"content-transfer-encoding"}{"value"}
exists $_[0]{$tree}{"content-transfer-encoding"}
exists $_[0]{$tree}{"content-transfer-encoding"}{"value"}
Truth table0%0/3
A and B
A= exists $_[0]{$tree}{"content-transfer-encoding"}B= exists $_[0]{$tree}{"content-transfer-encoding"}{"value"}
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | exists($_[0]->{$tree}->{'content-transfer-encoding'}->{value})) { | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $_[0]->{$tree}->{'content-transfer-encoding'}->{value} = lc($_[0]->{$tree}->{'content-transfer-encoding'}->{value}); | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if($_[0]->{$tree}->{'content-transfer-encoding'}->{value} eq "base64" || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$_[0]{$tree}{"content-transfer-encoding"}{"value"} eq "base64" or $_[0]{$tree}{"content-transfer-encoding"}{"value"} eq "quoted-printable" and $boundary
$_[0]{$tree}{"content-transfer-encoding"}{"value"} eq "quoted-printable" and $boundary
MC/DC0%0/3
$_[0]{$tree}{"content-transfer-encoding"}{"value"} eq "base64" or $_[0]{$tree}{"content-transfer-encoding"}{"value"} eq "quoted-printable" and $boundary
$_[0]{$tree}{"content-transfer-encoding"}{"value"} eq "base64"
$_[0]{$tree}{"content-transfer-encoding"}{"value"} eq "quoted-printable"
$boundary
Truth table0%0/4
A or B and C
A= $_[0]{$tree}{"content-transfer-encoding"}{"value"} eq "base64"B= $_[0]{$tree}{"content-transfer-encoding"}{"value"} eq "quoted-printable"C= $boundary
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | ($_[0]->{$tree}->{'content-transfer-encoding'}->{value} eq "quoted-printable" && $boundary)) { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | &set_filename($files, $_[0]->{$tree}); | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | my $filepath = ($args->{output_dir}) ? join("/", $args->{output_dir}, $_[0]->{$tree}->{'content-disposition'}->{filename}) : $_[0]->{$tree}->{'content-disposition'}->{filename}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | my $res = &decode_content($fhs, | ||||||||||||||||||||||||||||||||||||||||||
| 230 | $_[0]->{$tree}->{'content-transfer-encoding'}->{value}, | ||||||||||||||||||||||||||||||||||||||||||
| 231 | $filepath, | ||||||||||||||||||||||||||||||||||||||||||
| 232 | $boundary ? "--$boundary" : "", | ||||||||||||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||||||||||||
| 234 | mimetype => $_[0]->{$tree}->{'content-type'}->{value} || "", | ||||||||||||||||||||||||||||||||||||||||||
| 235 | checktype => $args->{'check_ctype'}, | ||||||||||||||||||||||||||||||||||||||||||
| 236 | action => $args->{'types_action'}, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | mimetypes => $args->{'ctypes'}, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_[0]{$tree}{'content-type'}{'value'} || ''
MC/DC0%0/1
$_[0]{$tree}{'content-type'}{'value'} || ''
$_[0]{$tree}{'content-type'}{'value'}
Truth table0%0/2
A
A= $_[0]{$tree}{'content-type'}{'value'}
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | mailbox => $mbox | ||||||||||||||||||||||||||||||||||||||||||
| 239 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | $_[0]->{$tree}->{'content-type'}->{value} = $res->[1] if($res->[1]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | $_[0]->{$tree}->{'content-disposition'}->{filepath} = $filepath unless($res->[2]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $tmp = 1; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | unless($_ = $res->[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $exclude = 1; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if($mbox && /$patterns[4]/o && scalar(@{[split(/\./o, $tree)]}) > 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$mbox and /$patterns[4]/o and scalar @{[split(/\./o, $tree, 0)];} > 2
$mbox and /$patterns[4]/o
MC/DC0%0/3
$mbox and /$patterns[4]/o and scalar @{[split(/\./o, $tree, 0)];} > 2
$mbox
/$patterns[4]/o
scalar @{[split(/\./o, $tree, 0)];} > 2
Truth table0%0/4
A and B and C
A= $mboxB= /$patterns[4]/oC= scalar @{[split(/\./o, $tree, 0)];} > 2
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $breakmsg = $_; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $_ = "--$boundary--\r\n"; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | if($mbox && /$patterns[4]/o) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mbox and /$patterns[4]/o
MC/DC0%0/2
$mbox and /$patterns[4]/o
$mbox
/$patterns[4]/o
Truth table0%0/3
A and B
A= $mboxB= /$patterns[4]/o
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if(scalar(@{[split(/\./o, $tree)]}) > 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $breakmsg = $_; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | $boundary ? ($_ = "--$boundary--\r\n") : return([$tree, $breakmsg]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | defined($fh) and &file_close($fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $header = 1; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my @ps = split(/\./o, $tree); | |||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $tree = join(".", ++$ps[0], "0"); | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | $tmp = ((length() <= 2) && /$patterns[2]/o) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $_ <= 2 and /$patterns[2]/o
MC/DC0%0/2
length $_ <= 2 and /$patterns[2]/o
length $_ <= 2
/$patterns[2]/o
Truth table0%0/3
A and B
A= length $_ <= 2B= /$patterns[2]/o
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | (defined($fh) || !$tmp) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fh or not $tmp
MC/DC0%0/2
defined $fh or not $tmp
defined $fh
not $tmp
Truth table0%0/3
A or not(B)
A= defined $fhB= not $tmp
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if($boundary) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if(index($_, "--$boundary--") >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | defined($fh) and &file_close($fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if($mbox && scalar(@{[split(/\./o, $tree)]}) == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mbox and scalar @{[split(/\./o, $tree, 0)];} == 2
MC/DC0%0/2
$mbox and scalar @{[split(/\./o, $tree, 0)];} == 2
$mbox
scalar @{[split(/\./o, $tree, 0)];} == 2
Truth table0%0/3
A and B
A= $mboxB= scalar @{[split(/\./o, $tree, 0)];} == 2
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ($tmp, $exclude) = (1, 1); | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $boundary = ""; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | } else { return([$tree, $breakmsg]); } | |||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | if(index($_, "--$boundary") >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | defined($fh) and &file_close($fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ($tmp, $header) = (1, 1); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $boundary = ""; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if($ph) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | return([$tree]) if($_[0]->{$base}->{'content-type'}->{value} eq "message/rfc822"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my @ps = split(/\./o, $tree); | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $ps[$#ps]++; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $tree = join("\.", @ps); | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | (!$exclude && $ph) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $exclude and $ph
MC/DC0%0/2
not $exclude and $ph
not $exclude
$ph
Truth table0%0/3
not(A) and B
A= not $excludeB= $ph
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if($check_ctype && $args->{check_ctype}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$check_ctype and $args->{"check_ctype"}
MC/DC0%0/2
$check_ctype and $args->{"check_ctype"}
$check_ctype
$args->{"check_ctype"}
Truth table0%0/3
A and B
A= $check_ctypeB= $args->{"check_ctype"}
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ($tmpbuff .= $_) =~ s/^[\n\r\t]+//o; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if(length($tmpbuff) > BUFFSIZE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | $_[0]->{$tree}->{'content-type'}->{value} ||= ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[0]{$tree}{"content-type"}{"value"} ||= ""
MC/DC0%0/1
$_[0]{$tree}{"content-type"}{"value"} ||= ""
$_[0]{$tree}{"content-type"}{"value"}
Truth table0%0/2
A
A= $_[0]{$tree}{"content-type"}{"value"}
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if(my $ct = set_content_type($tmpbuff, $_[0]->{$tree}->{'content-type'}->{value})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $_[0]->{$tree}->{'content-type'}->{value} = $ct; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $tmpbuff = ""; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $check_ctype = 0; | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if($exclude = exists($args->{'ctypes'}->{$_[0]->{$tree}->{'content-type'}->{value}}) ? ($args->{'types_action'} ? 0 : 1) : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | scalar(keys(%{$args->{'ctypes'}})) ? ($args->{'types_action'} ? 1 : 0) : ($args->{'types_action'} ? 0 : 1)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if(defined($fh)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | &file_close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | unlink($_[0]->{$tree}->{'content-disposition'}->{filepath}); | |||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | delete($_[0]->{$tree}->{'content-disposition'}->{filepath}); | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | unless(defined($fh)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | &set_filename($files, $_[0]->{$tree}); | |||||||||||||||||||||||||||||||||||||||||
| 314 | $_[0]->{$tree}->{'content-disposition'}->{filepath} = ($args->{output_dir}) ? | ||||||||||||||||||||||||||||||||||||||||||
| 315 | join("/", $args->{output_dir}, $_[0]->{$tree}->{'content-disposition'}->{filename}) : | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $_[0]->{$tree}->{'content-disposition'}->{filename}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | defined($fh) and &file_close($fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $fh = &file_open($_[0]->{$tree}->{'content-disposition'}->{filepath}); | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | if(defined($fh)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if(!$ftmp && (length() <= 2) && /$patterns[2]/o) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $ftmp and length $_ <= 2 and /$patterns[2]/o
not $ftmp and length $_ <= 2
MC/DC0%0/3
not $ftmp and length $_ <= 2 and /$patterns[2]/o
not $ftmp
length $_ <= 2
/$patterns[2]/o
Truth table0%0/4
not(A) and B and C
A= not $ftmpB= length $_ <= 2C= /$patterns[2]/o
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $ftmp .= $_; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | if($ftmp) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $_ = join("", $ftmp, $_); | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $ftmp = ""; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | print $fh ($_[0]->{$tree}->{'content-transfer-encoding'}->{value} eq "quoted-printable") ? rfc822_qprint($_) : $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | exists($_[0]->{$tree}->{'content-length'}) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if(($ctlength += length()) >= $_[0]->{$tree}->{'content-length'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | defined($fh) and &file_close($fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $exclude = 1; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | defined($fh) and &file_close($fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | return([$tree, ""]); | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | sub file_close { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_close: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | close($_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | undef($_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub file_open { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_open: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | local *FILE; | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if($path =~ /^(.+)$/) { $path = $1; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | open(FILE, ">$path") or die("MIME::Explode: Couldn't open $path for writing: $!\n"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | binmode(FILE); | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | return *FILE; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | sub header2hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header2hash: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $header = pop; | |||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my $params = semicolon_split($header); | |||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | $_[0]->{value} = shift(@{$params}) || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @{$params;} || ''
MC/DC0%0/1
shift @{$params;} || ''
shift @{$params;}
Truth table0%0/2
A
A= shift @{$params;}
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | map {/$patterns[0]/o and $_[0]->{lc($1)} = $2; } @{$params}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
/$patterns[0]/o && ($_[0]{lc $1} = $2)
MC/DC0%0/2
/$patterns[0]/o && ($_[0]{lc $1} = $2)
/$patterns[0]/o
($_[0]{lc $1} = $2)
Truth table0%0/3
A && B
A= /$patterns[0]/oB= ($_[0]{lc $1} = $2)
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub set_filename { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_filename: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $files = shift; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $h = shift; | |||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $file = "file"; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if(exists($h->{'content-disposition'}->{filename})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $file = $h->{'content-disposition'}->{filename}; | |||||||||||||||||||||||||||||||||||||||||
| 373 | } elsif(exists($h->{'content-type'}->{name})) { | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $file = $h->{'content-type'}->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 375 | } elsif(exists($h->{'content-type'}->{value})) { | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $ctype = lc($h->{'content-type'}->{value}); | |||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | $file .= $content_type{$ctype} || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$content_type{$ctype} || ''
MC/DC0%0/1
$content_type{$ctype} || ''
$content_type{$ctype}
Truth table0%0/2
A
A= $content_type{$ctype}
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $file =~ s/^[ \.]+$/file/o; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $h->{'content-disposition'}->{filename} = &check_filename($files, $file); | |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $h->{'content-transfer-encoding'}->{value} = "" unless(exists($h->{'content-transfer-encoding'}->{value})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | bootstrap MIME::Explode $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||