| 1 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 2 | # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de> | ||||||||||||||||||||||||||||
| 3 | # File: GX/HTTP/Parser/Body/MultiPart.pm | ||||||||||||||||||||||||||||
| 4 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | package GX::HTTP::Parser::Body::MultiPart; | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 15 | ▶ | use GX::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 15 | ▶ | use GX::HTTP::Constants qw( CRLF CRLFCRLF ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use GX::HTTP::Headers; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use GX::HTTP::Parameters; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 15 | ▶ | use GX::HTTP::Upload; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 15 | ▶ | use GX::HTTP::Uploads; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 15 | ▶ | use File::Temp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 19 | # Constants | ||||||||||||||||||||||||||||
| 20 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 15 | ▶ | use constant { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 15 | BUFFER_SIZE => 8192, | |||||||||||||||||||||||||||
| 24 | STATE_PARSING => 1, | ||||||||||||||||||||||||||||
| 25 | STATE_DONE => 2 | ||||||||||||||||||||||||||||
| 26 | 15 | }; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 30 | # Class setup | ||||||||||||||||||||||||||||
| 31 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 15 | ▶ | use GX::Class; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 15 | extends 'GX::HTTP::Parser::Body'; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 15 | build; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 41 | # Public methods | ||||||||||||||||||||||||||||
| 42 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 344 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 344 | my $self = shift; | |||||||||||||||||||||||||||
| 47 | 344 | my $body = shift; | |||||||||||||||||||||||||||
| 48 | 344 | ▶ | my $buffer_size = shift || BUFFER_SIZE; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 8192
MC/DC100%1/1
shift() || 8192
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 344 | ▶ | $self->{'boundary'} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 344 | ▶ | my $content = $body->open or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 344 | my $context = { | |||||||||||||||||||||||||||
| 55 | 'buffer' => CRLF, | ||||||||||||||||||||||||||||
| 56 | 'state' => STATE_PARSING, | ||||||||||||||||||||||||||||
| 57 | 'parse' => \&_parse_boundary, | ||||||||||||||||||||||||||||
| 58 | 'part' => undef, | ||||||||||||||||||||||||||||
| 59 | 'result' => {} | ||||||||||||||||||||||||||||
| 60 | }; | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | READ: | ||||||||||||||||||||||||||||
| 63 | 344 | ▶ | while ( $content->read( my $buffer, $buffer_size ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 2228 | $context->{'buffer'} .= $buffer; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 2228 | ▶ | while ( $context->{'state'} == STATE_PARSING ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 5900 | ▶ | $context->{'parse'}->( $self, $context ) or next READ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 339 | last READ; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 344 | ▶ | return $context->{'state'} == STATE_DONE ? $context->{'result'} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 81 | # Private methods | ||||||||||||||||||||||||||||
| 82 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1241 | ▶ | sub _parse_body { | ||||||||||||||||||||||||||
|
Subroutine
_parse_body: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 1241 | my $self = shift; | |||||||||||||||||||||||||||
| 87 | 1241 | my $context = shift; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 1241 | my $part = $context->{'part'}; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 1241 | my $index = index( $context->{'buffer'}, $self->{'delimiter'} ); | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 1241 | ▶ | if ( $index < 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 242 | ▶ | if ( $part->{'fh'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 12 | $part->{'fh'}->print( substr( $context->{'buffer'}, 0, -76, '' ) ); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | else { | ||||||||||||||||||||||||||||
| 99 | 230 | $part->{'data'} .= substr( $context->{'buffer'}, 0, -76, '' ); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 242 | return 0; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 999 | ▶ | if ( $part->{'fh'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 9 | my $fh = $part->{'fh'}; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 9 | $fh->print( substr( $context->{'buffer'}, 0, $index, '' ) ); | |||||||||||||||||||||||||||
| 111 | 9 | $fh->flush; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | my $upload = GX::HTTP::Upload->new( | ||||||||||||||||||||||||||||
| 114 | file => $fh->filename, | ||||||||||||||||||||||||||||
| 115 | filename => $part->{'filename'}, | ||||||||||||||||||||||||||||
| 116 | name => $part->{'name'}, | ||||||||||||||||||||||||||||
| 117 | 9 | headers => $part->{'headers'}, | |||||||||||||||||||||||||||
| 118 | cleanup => 1 | ||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 9 | $fh->unlink_on_destroy( 0 ); | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 9 | %$part = ( 'upload' => $upload ); | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 9 | ▶ | $context->{'result'}{'uploads'} ||= GX::HTTP::Uploads->new; | ||||||||||||||||||||||||||
|
Condition66%2/3
$context->{"result"}{"uploads"} ||= "GX::HTTP::Uploads"->new
MC/DC0%0/2
$context->{"result"}{"uploads"} ||= "GX::HTTP::Uploads"->new
$context->{"result"}{"uploads"}
"GX::HTTP::Uploads"->new
Truth table66%2/3
A ||= B
A= $context->{"result"}{"uploads"}B= "GX::HTTP::Uploads"->new
| |||||||||||||||||||||||||||||
| 126 | 9 | $context->{'result'}{'uploads'}->add( $upload ); | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | else { | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 990 | $part->{'data'} .= substr( $context->{'buffer'}, 0, $index, '' ); | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 990 | ▶ | $context->{'result'}{'parameters'} ||= GX::HTTP::Parameters->new; | ||||||||||||||||||||||||||
|
Condition66%2/3
$context->{"result"}{"parameters"} ||= "GX::HTTP::Parameters"->new
MC/DC0%0/2
$context->{"result"}{"parameters"} ||= "GX::HTTP::Parameters"->new
$context->{"result"}{"parameters"}
"GX::HTTP::Parameters"->new
Truth table66%2/3
A ||= B
A= $context->{"result"}{"parameters"}B= "GX::HTTP::Parameters"->new
| |||||||||||||||||||||||||||||
| 134 | 990 | $context->{'result'}{'parameters'}->add( $part->{'name'} => $part->{'data'} ); | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 999 | $context->{'part'} = undef; | |||||||||||||||||||||||||||
| 139 | 999 | $context->{'parse'} = \&_parse_boundary; | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 999 | return 1; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 1809 | ▶ | sub _parse_boundary { | ||||||||||||||||||||||||||
|
Subroutine
_parse_boundary: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 1809 | my $self = shift; | |||||||||||||||||||||||||||
| 148 | 1809 | my $context = shift; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 1809 | my $index = index( $context->{'buffer'}, $self->{'delimiter'} ); | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 1809 | ▶ | if ( $index < 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 79 | substr( $context->{'buffer'}, 0, -76, '' ); | |||||||||||||||||||||||||||
| 154 | 79 | return 0; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 1730 | ▶ | if ( $index > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 337 | substr( $context->{'buffer'}, 0, $index, '' ); | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 1730 | ▶ | if ( length( $context->{'buffer'} ) < length( $self->{'delimiter_end'} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 54 | return 0; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 1676 | ▶ | if ( index( $context->{'buffer'}, $self->{'delimiter_end'} ) == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 339 | $context->{'state'} = STATE_DONE; | |||||||||||||||||||||||||||
| 167 | 339 | $context->{'parse'} = undef; | |||||||||||||||||||||||||||
| 168 | 339 | return 1; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 1337 | $index = index( $context->{'buffer'}, CRLF, 2 ); | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 1337 | ▶ | if ( $index < 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | 0 | return 0; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 1337 | substr( $context->{'buffer'}, 0, $index + 2, '' ); | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 1337 | push( @{$context->{'result'}{'parts'}}, $context->{'part'} = {} ); | |||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 1337 | $context->{'parse'} = \&_parse_header; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 1337 | return 1; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 2850 | ▶ | sub _parse_header { | ||||||||||||||||||||||||||
|
Subroutine
_parse_header: called CC=13 SCAR=25.8
| |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 2850 | my $self = shift; | |||||||||||||||||||||||||||
| 190 | 2850 | my $context = shift; | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 2850 | ▶ | if ( length( $context->{'buffer'} ) < length( $self->{'delimiter'} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 325 | return 0; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | # No header | ||||||||||||||||||||||||||||
| 197 | 2525 | ▶ | if ( substr( $context->{'buffer'}, 0, 2 ) eq CRLF ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 2 | ▶ | if ( substr( $context->{'buffer'}, 0, length( $self->{'delimiter'} ) ) eq $self->{'delimiter'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 2 | $context->{'parse'} = \&_parse_boundary; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | else { | ||||||||||||||||||||||||||||
| 203 | 0 | substr( $context->{'buffer'}, 0, 2, '' ); | |||||||||||||||||||||||||||
| 204 | 0 | $context->{'parse'} = \&_parse_body; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 2 | return 1; | |||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 2523 | my $index = index( $context->{'buffer'}, CRLFCRLF ); | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 2523 | ▶ | if ( $index < 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 928 | return 0; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 1595 | ▶ | if ( length( $context->{'buffer'} ) < $index + length( $self->{'delimiter'} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 261 | return 0; | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 1334 | my $part = $context->{'part'}; | |||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 1334 | $part->{'headers'} = GX::HTTP::Headers->parse( substr( $context->{'buffer'}, 0, $index ) ); | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 1334 | substr( $context->{'buffer'}, 0, $index + 2, '' ); | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 1334 | my $content_disposition = $part->{'headers'}->content_disposition; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 1334 | ▶ | if ( $content_disposition && $content_disposition =~ / name="?([^";\s]+)"?/i ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$content_disposition and $content_disposition =~ / name="?([^";\s]+)"?/i
MC/DC50%1/2
$content_disposition and $content_disposition =~ / name="?([^";\s]+)"?/i
$content_disposition
$content_disposition =~ / name="?([^";\s]+)"?/i
Truth table66%2/3
A and B
A= $content_dispositionB= $content_disposition =~ / name="?([^";\s]+)"?/i
| |||||||||||||||||||||||||||||
| 230 | 1006 | $part->{'name'} = $1; | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | else { | ||||||||||||||||||||||||||||
| 233 | # Discard this part | ||||||||||||||||||||||||||||
| 234 | 328 | $context->{'parse'} = \&_parse_boundary; | |||||||||||||||||||||||||||
| 235 | 328 | return 1; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 1006 | ▶ | if ( $content_disposition =~ / filename="?([^"]*)"?/i ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 12 | ▶ | if ( $self->{'discard_uploads'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | # Discard this part | ||||||||||||||||||||||||||||
| 242 | 3 | $context->{'parse'} = \&_parse_boundary; | |||||||||||||||||||||||||||
| 243 | 3 | return 1; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 9 | $part->{'filename'} = $1; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | $part->{'fh'} = File::Temp->new( | ||||||||||||||||||||||||||||
| 249 | UNLINK => 1, | ||||||||||||||||||||||||||||
| 250 | 9 | ▶ | $self->{'tmp_dir'} ? ( DIR => $self->{'tmp_dir'} ) : () | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 251 | ) or throw "Cannot create temporary file ($!)"; | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 1003 | ▶ | if ( substr( $context->{'buffer'}, 0, length( $self->{'delimiter'} ) ) eq $self->{'delimiter'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 4 | $context->{'parse'} = \&_parse_boundary; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | else { | ||||||||||||||||||||||||||||
| 259 | 999 | substr( $context->{'buffer'}, 0, 2, '' ); | |||||||||||||||||||||||||||
| 260 | 999 | $context->{'parse'} = \&_parse_body; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 1003 | return 1; | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 269 | # Internal methods | ||||||||||||||||||||||||||||
| 270 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 346 | ▶ | sub __initialize { | ||||||||||||||||||||||||||
|
Subroutine
__initialize: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 346 | my $self = shift; | |||||||||||||||||||||||||||
| 275 | 346 | my $args = shift; | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 346 | ▶ | if ( $args->{'content_type'} && $args->{'content_type'} =~ /boundary="?([^";,]+)"?/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args->{"content_type"} and $args->{"content_type"} =~ /boundary="?([^";,]+)"?/
MC/DC0%0/2
$args->{"content_type"} and $args->{"content_type"} =~ /boundary="?([^";,]+)"?/
$args->{"content_type"}
$args->{"content_type"} =~ /boundary="?([^";,]+)"?/
Truth table33%1/3
A and B
A= $args->{"content_type"}B= $args->{"content_type"} =~ /boundary="?([^";,]+)"?/
| |||||||||||||||||||||||||||||
| 278 | 346 | $self->{'boundary'} = $1; | |||||||||||||||||||||||||||
| 279 | 346 | $self->{'delimiter'} = CRLF . '--' . $1; | |||||||||||||||||||||||||||
| 280 | 346 | $self->{'delimiter_end'} = CRLF . '--' . $1 . '--'; | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 346 | return; | |||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 15 | 1; | |||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | __END__ | ||||||||||||||||||||||||||||