line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Minimal; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This program is licensed under the same terms as Perl. |
4
|
|
|
|
|
|
|
# See http://dev.perl.org/licenses/ |
5
|
|
|
|
|
|
|
# Copyright Jerilyn Franz. All Rights Reserved. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# I don't 'use warnings;' here because it pulls in ~ 20Kbytes of code |
8
|
|
|
|
|
|
|
# and is incompatible with perl's older than 5.6 |
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
48
|
use strict; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
7134
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#### |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _internal_param_mime { |
15
|
7750
|
|
|
7750
|
|
8548
|
my $pkg = __PACKAGE__; |
16
|
7750
|
|
|
|
|
9313
|
my $vars = shift->{$pkg}; |
17
|
|
|
|
|
|
|
|
18
|
7750
|
|
|
|
|
8654
|
my @result = (); |
19
|
7750
|
100
|
|
|
|
14068
|
if ($#_ == -1) { |
|
|
100
|
|
|
|
|
|
20
|
750
|
|
|
|
|
784
|
@result = @{$vars->{'field_names'}}; |
|
750
|
|
|
|
|
1544
|
|
21
|
|
|
|
|
|
|
} elsif ($#_ == 0) { |
22
|
6250
|
|
|
|
|
8567
|
my ($fname)=@_; |
23
|
6250
|
100
|
|
|
|
11294
|
if (defined($vars->{'field'}->{$fname})) { |
24
|
4750
|
|
|
|
|
4739
|
@result = @{$vars->{'field'}->{$fname}->{'mime_type'}}; |
|
4750
|
|
|
|
|
8717
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} else { |
27
|
750
|
|
|
|
|
2232
|
require Carp; |
28
|
750
|
|
|
|
|
72486
|
Carp::confess($pkg . "::param_mime() - incorrect number of calling parameters (either 1 or no parameters expected)"); |
29
|
|
|
|
|
|
|
} |
30
|
7000
|
100
|
|
|
|
12106
|
if (wantarray) { |
|
|
100
|
|
|
|
|
|
31
|
3000
|
|
|
|
|
7118
|
return @result; |
32
|
|
|
|
|
|
|
} elsif ($#result > -1) { |
33
|
3250
|
|
|
|
|
6668
|
return $result[0]; |
34
|
|
|
|
|
|
|
} else { |
35
|
750
|
|
|
|
|
1603
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#### |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _internal_param_filename { |
42
|
7750
|
|
|
7750
|
|
8564
|
my $pkg = __PACKAGE__; |
43
|
7750
|
|
|
|
|
9105
|
my $vars = shift->{$pkg}; |
44
|
|
|
|
|
|
|
|
45
|
7750
|
|
|
|
|
8424
|
my @result = (); |
46
|
7750
|
100
|
|
|
|
13571
|
if ($#_ == -1) { |
|
|
100
|
|
|
|
|
|
47
|
750
|
|
|
|
|
811
|
@result = @{$vars->{'field_names'}}; |
|
750
|
|
|
|
|
1434
|
|
48
|
|
|
|
|
|
|
} elsif ($#_ == 0) { |
49
|
6250
|
|
|
|
|
8313
|
my ($fname)=@_; |
50
|
6250
|
100
|
|
|
|
10715
|
if (defined($vars->{'field'}->{$fname})) { |
51
|
4750
|
|
|
|
|
4553
|
@result = @{$vars->{'field'}->{$fname}->{'filename'}}; |
|
4750
|
|
|
|
|
8459
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} else { |
54
|
750
|
|
|
|
|
2095
|
require Carp; |
55
|
750
|
|
|
|
|
59999
|
Carp::confess($pkg . "::param_filename() - incorrect number of calling parameters (either 1 or no parameters expected)"); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
7000
|
100
|
|
|
|
11742
|
if (wantarray) { |
|
|
100
|
|
|
|
|
|
59
|
3000
|
|
|
|
|
6829
|
return @result; |
60
|
|
|
|
|
|
|
} elsif ($#result > -1) { |
61
|
3250
|
|
|
|
|
6290
|
return $result[0]; |
62
|
750
|
|
|
|
|
1404
|
} else { return; } |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#### |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _burst_multipart_buffer { |
68
|
1252
|
|
|
1252
|
|
1644
|
my $self = shift; |
69
|
1252
|
|
|
|
|
1491
|
my $pkg = __PACKAGE__; |
70
|
|
|
|
|
|
|
|
71
|
1252
|
|
|
|
|
2592
|
my ($buffer,$bdry)=@_; |
72
|
|
|
|
|
|
|
|
73
|
1252
|
|
|
|
|
1813
|
my $vars = $self->{$pkg}; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Special case boundaries causing problems with 'split' |
76
|
1252
|
100
|
|
|
|
3814
|
if ($bdry =~ m#[^A-Za-z0-9',-./:=]#s) { |
77
|
561
|
|
|
|
|
795
|
my $nbdry = $bdry; |
78
|
561
|
|
|
|
|
2306
|
$nbdry =~ s/([^A-Za-z0-9',-.\/:=])/ord($1)/egs; |
|
561
|
|
|
|
|
2360
|
|
79
|
561
|
|
|
|
|
1289
|
my $quoted_boundary = quotemeta ($nbdry); |
80
|
561
|
|
|
|
|
8967
|
while ($buffer =~ m/$quoted_boundary/s) { |
81
|
6
|
|
|
|
|
160
|
$nbdry .= chr(int(rand(25))+65); |
82
|
6
|
|
|
|
|
81
|
$quoted_boundary = quotemeta ($nbdry); |
83
|
|
|
|
|
|
|
} |
84
|
561
|
|
|
|
|
1252
|
my $old_boundary = quotemeta($bdry); |
85
|
561
|
|
|
|
|
7830
|
$buffer =~ s/$old_boundary/$nbdry/gs; |
86
|
561
|
|
|
|
|
1434
|
$bdry = $nbdry; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
1252
|
|
|
|
|
2646
|
$bdry = "--$bdry(--)?\015\012"; |
90
|
1252
|
|
|
|
|
29422
|
my @pairs = split(/$bdry/, $buffer); |
91
|
|
|
|
|
|
|
|
92
|
1252
|
|
|
|
|
3480
|
foreach my $pair (@pairs) { |
93
|
12518
|
100
|
|
|
|
18932
|
next if (! defined $pair); |
94
|
7511
|
|
|
|
|
8951
|
chop $pair; # Trailing \015 |
95
|
7511
|
|
|
|
|
7506
|
chop $pair; # Trailing \012 |
96
|
7511
|
50
|
|
|
|
11059
|
last if ($pair eq "--"); |
97
|
7511
|
100
|
|
|
|
14026
|
next if (! $pair); |
98
|
|
|
|
|
|
|
|
99
|
5007
|
|
|
|
|
12293
|
my ($header, $data) = split(/\015\012\015\012/s,$pair,2); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# parse the header |
102
|
5007
|
|
|
|
|
11152
|
$header =~ s/\015\012/\012/osg; |
103
|
5007
|
|
|
|
|
9536
|
my @headerlines = split(/\012/so,$header); |
104
|
5007
|
|
|
|
|
6203
|
my $name = ''; |
105
|
5007
|
|
|
|
|
5357
|
my $filename = ''; |
106
|
5007
|
|
|
|
|
5164
|
my $mime_type = 'text/plain'; |
107
|
|
|
|
|
|
|
|
108
|
5007
|
|
|
|
|
6249
|
foreach my $headfield (@headerlines) { |
109
|
7259
|
|
|
|
|
14346
|
my ($fname,$fdata) = split(/: /,$headfield,2); |
110
|
7259
|
100
|
|
|
|
17199
|
if ($fname =~ m/^Content-Type$/io) { |
111
|
2252
|
|
|
|
|
2629
|
$mime_type=$fdata; |
112
|
|
|
|
|
|
|
} |
113
|
7259
|
100
|
|
|
|
14187
|
if ($fname =~ m/^Content-Disposition$/io) { |
114
|
5007
|
|
|
|
|
9974
|
my @dispositionlist = split(/; /,$fdata); |
115
|
5007
|
|
|
|
|
6790
|
foreach my $dispitem (@dispositionlist) { |
116
|
12767
|
100
|
|
|
|
18205
|
next if ($dispitem eq 'form-data'); |
117
|
7760
|
|
|
|
|
15112
|
my ($dispfield,$dispdata) = split(/=/,$dispitem,2); |
118
|
7760
|
|
|
|
|
19389
|
$dispdata =~ s/^\"//o; |
119
|
7760
|
|
|
|
|
16919
|
$dispdata =~ s/\"$//o; |
120
|
7760
|
100
|
|
|
|
14177
|
$name = $dispdata if ($dispfield eq 'name'); |
121
|
7760
|
100
|
|
|
|
16775
|
$filename = $dispdata if ($dispfield eq 'filename'); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
5007
|
100
|
|
|
|
12511
|
if (! defined ($vars->{'field'}->{$name}->{'count'})) { |
127
|
4506
|
|
|
|
|
4809
|
push (@{$vars->{'field_names'}},$name); |
|
4506
|
|
|
|
|
8252
|
|
128
|
4506
|
|
|
|
|
7981
|
$vars->{'field'}->{$name}->{'count'} = 0; |
129
|
|
|
|
|
|
|
} |
130
|
5007
|
|
|
|
|
6258
|
my $record = $vars->{'field'}->{$name}; |
131
|
5007
|
|
|
|
|
5337
|
my $f_count = $record->{'count'}; |
132
|
5007
|
|
|
|
|
5193
|
$record->{'count'}++; |
133
|
5007
|
|
|
|
|
8485
|
$record->{'value'}->[$f_count] = $data; |
134
|
5007
|
|
|
|
|
7401
|
$record->{'filename'}->[$f_count] = $filename; |
135
|
5007
|
|
|
|
|
10580
|
$record->{'mime_type'}->[$f_count] = $mime_type; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#### |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |