| 1 | package CGI::Tiny::Multipart; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Tiny multipart/form-data form parser | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # This file is part of CGI::Tiny which is released under: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # The Artistic License 2.0 (GPL Compatible) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # See the documentation for CGI::Tiny for full license details. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | our $VERSION = '1.003'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | our @EXPORT_OK = qw(extract_multipart_boundary parse_multipart_form_data); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use constant DEFAULT_REQUEST_BODY_BUFFER => 262144; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 18 | ▶ | sub extract_multipart_boundary { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_multipart_boundary: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 18 | my ($content_type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 18 | my ($boundary_quoted, $boundary_unquoted) = $content_type =~ m/;\s*boundary\s*=\s*(?:"((?:\\[\\"]|[^"])+)"|([^";]+))/i; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 18 | ▶ | $boundary_quoted =~ s/\\([\\"])/$1/g if defined $boundary_quoted; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 18 | ▶ | return defined $boundary_quoted ? $boundary_quoted : $boundary_unquoted; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 25 | ▶ | sub parse_multipart_form_data { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_multipart_form_data: called CC=50 SCAR=40.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 25 | my ($input, $length, $boundary, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 25 | ▶ | $options ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options ||= {}
MC/DC100%1/1
$options ||= {}
$options
Truth table100%2/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 25 | my $input_is_scalar = ref $input eq 'SCALAR'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 25 | ▶ | binmode $input unless $input_is_scalar; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 25 | ▶ | my $remaining = 0 + ($length || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$length || 0
MC/DC0%0/1
$length || 0
$length
Truth table50%1/2
A
A= $length
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 25 | my $next_boundary = "\r\n--$boundary\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 25 | my $end_boundary = "\r\n--$boundary--"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 25 | ▶ | my $buffer_size = 0 + ($options->{buffer_size} || DEFAULT_REQUEST_BODY_BUFFER); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->{'buffer_size'} || 262144
MC/DC100%1/1
$options->{'buffer_size'} || 262144
$options->{'buffer_size'}
Truth table100%2/2
A
A= $options->{'buffer_size'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 25 | my $buffer = "\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 25 | my (%state, @parts, $current); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 25 | ▶ | READER: while ($remaining > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 25 | ▶ | if ($input_is_scalar) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 17 | $buffer .= substr $$input, 0, $remaining; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 17 | $remaining = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 8 | ▶ | my $chunk = $remaining < $buffer_size ? $remaining : $buffer_size; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | ▶ | last unless my $read = read $input, $buffer, $chunk, length $buffer; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | $remaining -= $read; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 25 | ▶ | unless ($state{parsing_headers} or $state{parsing_body}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$state{"parsing_headers"} or $state{"parsing_body"}
MC/DC0%0/2
$state{"parsing_headers"} or $state{"parsing_body"}
$state{"parsing_headers"}
$state{"parsing_body"}
Truth table33%1/3
A or B
A= $state{"parsing_headers"}B= $state{"parsing_body"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 25 | my $next_pos = index $buffer, $next_boundary; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 25 | my $end_pos = index $buffer, $end_boundary; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 25 | ▶ | if ($next_pos >= 0 and ($end_pos < 0 or $end_pos > $next_pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
$next_pos >= 0 and $end_pos < 0 || $end_pos > $next_pos
$end_pos < 0 or $end_pos > $next_pos
MC/DC100%3/3
$next_pos >= 0 and $end_pos < 0 || $end_pos > $next_pos
$next_pos >= 0
$end_pos < 0
$end_pos > $next_pos
Truth table100%4/4
A and B or C
A= $next_pos >= 0B= $end_pos < 0C= $end_pos > $next_pos
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 22 | substr $buffer, 0, $next_pos + length($next_boundary), ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 22 | $state{parsing_headers} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 22 | push @parts, $current = {headers => {}, name => undef, filename => undef, size => 0}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } elsif ($end_pos >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | $state{done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | last; # end of multipart data | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | next; # read more to find start of multipart data | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 22 | ▶ | while (length $buffer) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 234 | ▶ | if ($state{parsing_headers}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 118 | ▶ | while ((my $pos = index $buffer, "\r\n") >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 295 | ▶ | if ($pos == 0) { # end of headers | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 116 | $state{parsing_headers} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 116 | $state{parsing_body} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 116 | $state{parsed_optional_crlf} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 116 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 179 | my $header = substr $buffer, 0, $pos + 2, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 179 | my ($name, $value) = split /\s*:\s*/, $header, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 179 | ▶ | return undef unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 177 | $value =~ s/\s*\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 177 | $current->{headers}{lc $name} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 177 | ▶ | if (lc $name eq 'content-disposition') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 115 | ▶ | while ($value =~ m/;\s*([^=\s]+)\s*=\s*(?:"((?:\\[\\"]|[^"])*)"|([^";]*))/ig) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 160 | my ($field_name, $field_quoted, $field_unquoted) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 160 | ▶ | next unless lc $field_name eq 'name' or lc $field_name eq 'filename'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
lc $field_name eq "name" or lc $field_name eq "filename"
MC/DC0%0/2
lc $field_name eq "name" or lc $field_name eq "filename"
lc $field_name eq "name"
lc $field_name eq "filename"
Truth table66%2/3
A or B
A= lc $field_name eq "name"B= lc $field_name eq "filename"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 160 | ▶ | $field_quoted =~ s/\\([\\"])/$1/g if defined $field_quoted; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 160 | ▶ | $current->{lc $field_name} = defined $field_quoted ? $field_quoted : $field_unquoted; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 116 | ▶ | next READER if $state{parsing_headers}; # read more to find end of headers | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 116 | my $append = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 116 | my $next_pos = index $buffer, $next_boundary; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 116 | my $end_pos = index $buffer, $end_boundary; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 116 | ▶ | if ($next_pos >= 0 and ($end_pos < 0 or $end_pos > $next_pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%4/6
$next_pos >= 0 and $end_pos < 0 || $end_pos > $next_pos
$end_pos < 0 or $end_pos > $next_pos
MC/DC33%1/3
$next_pos >= 0 and $end_pos < 0 || $end_pos > $next_pos
$next_pos >= 0
$end_pos < 0
$end_pos > $next_pos
Truth table75%3/4
A and B or C
A= $next_pos >= 0B= $end_pos < 0C= $end_pos > $next_pos
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 97 | ▶ | if (!$state{parsed_optional_crlf} and $next_pos >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $state{"parsed_optional_crlf"} and $next_pos >= 2
MC/DC50%1/2
not $state{"parsed_optional_crlf"} and $next_pos >= 2
not $state{"parsed_optional_crlf"}
$next_pos >= 2
Truth table66%2/3
not(A) and B
A= not $state{"parsed_optional_crlf"}B= $next_pos >= 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 84 | substr $buffer, 0, 2, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 84 | $next_pos -= 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 84 | $state{parsed_optional_crlf} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 97 | $append = substr $buffer, 0, $next_pos, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 97 | substr $buffer, 0, length($next_boundary), ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 97 | $state{parsing_body} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 97 | $state{parsing_headers} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } elsif ($end_pos >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 19 | ▶ | if (!$state{parsed_optional_crlf} and $end_pos >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $state{"parsed_optional_crlf"} and $end_pos >= 2
MC/DC0%0/2
not $state{"parsed_optional_crlf"} and $end_pos >= 2
not $state{"parsed_optional_crlf"}
$end_pos >= 2
Truth table33%1/3
not(A) and B
A= not $state{"parsed_optional_crlf"}B= $end_pos >= 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 19 | substr $buffer, 0, 2, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 19 | $end_pos -= 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 19 | $state{parsed_optional_crlf} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 19 | $append = substr $buffer, 0, $end_pos; # no replacement, we're done here | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 19 | $state{parsing_body} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 19 | $state{done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } elsif (length($buffer) > length($next_boundary) + 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if (!$state{parsed_optional_crlf}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | substr $buffer, 0, 2, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $state{parsed_optional_crlf} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $append = substr $buffer, 0, length($buffer) - length($next_boundary), ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 116 | $current->{size} += length $append; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 116 | ▶ | unless (defined $current->{filename} and $options->{discard_files}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $current->{"filename"} and $options->{"discard_files"}
MC/DC100%2/2
defined $current->{"filename"} and $options->{"discard_files"}
defined $current->{"filename"}
$options->{"discard_files"}
Truth table100%3/3
A and B
A= defined $current->{"filename"}B= $options->{"discard_files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 103 | ▶ | if ($options->{parse_as_files} or (defined $current->{filename} and !defined $options->{parse_as_files})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$options->{"parse_as_files"} or defined $current->{"filename"} and not defined $options->{"parse_as_files"}
defined $current->{"filename"} and not defined $options->{"parse_as_files"}
MC/DC100%3/3
$options->{"parse_as_files"} or defined $current->{"filename"} and not defined $options->{"parse_as_files"}
$options->{"parse_as_files"}
defined $current->{"filename"}
not defined $options->{"parse_as_files"}
Truth table100%4/4
A or B and not(C)
A= $options->{"parse_as_files"}B= defined $current->{"filename"}C= not defined $options->{"parse_as_files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 41 | my $is_eof = !$state{parsing_body}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 41 | ▶ | if (defined $options->{on_file_buffer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 12 | $options->{on_file_buffer}->($append, my $dummy = $current, $is_eof); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # create temp file even if empty | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 29 | ▶ | unless (defined $current->{file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 29 | require File::Temp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 29 | ▶ | $current->{file} = File::Temp->new(@{$options->{tempfile_args} || []}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->{'tempfile_args'} || []
MC/DC100%1/1
$options->{'tempfile_args'} || []
$options->{'tempfile_args'}
Truth table100%2/2
A
A= $options->{'tempfile_args'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 29 | binmode $current->{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 29 | print {$current->{file}} $append; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 29 | ▶ | if ($is_eof) { # finalize temp file | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 29 | $current->{file}->flush; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 29 | seek $current->{file}, 0, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 62 | ▶ | $current->{content} = '' unless defined $current->{content}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 62 | $current->{content} .= $append; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 116 | ▶ | last READER if $state{done}; # end of multipart data | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 97 | ▶ | next READER if $state{parsing_body}; # read more to find end of part | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # new part started | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 97 | push @parts, $current = {headers => {}, name => undef, filename => undef, size => 0}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 23 | ▶ | return undef unless $state{done}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 20 | return \@parts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||