line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This is a patched version by Skriptke of CGI::Minimal ver 1.29 by |
4
|
|
|
|
|
|
|
# Benjamin Franz |
5
|
|
|
|
|
|
|
# http://search.cpan.org/dist/CGI-Minimal/ |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Licensed under the GNU GPL. |
8
|
|
|
|
|
|
|
# http://nes.sourceforge.net/ |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# NES Version 1.03 |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Minimal.pm |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Nes::Minimal; |
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
15796
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# I don't 'use warnings;' here because it pulls in ~ 40Kbytes of code and |
21
|
|
|
|
|
|
|
# interferes with 5.005 and earlier versions of Perl. |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
# I don't use vars qw ($_query $VERSION $form_initial_read $_BUFFER); for |
24
|
|
|
|
|
|
|
# because it also pulls in warnings under later versions of perl. |
25
|
|
|
|
|
|
|
# The code is clean - but the pragmas cause performance issues. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$Nes::Minimal::_query = undef; |
28
|
|
|
|
|
|
|
$Nes::Minimal::form_initial_read = undef; |
29
|
|
|
|
|
|
|
$Nes::Minimal::_BUFFER = undef; |
30
|
|
|
|
|
|
|
$Nes::Minimal::_allow_hybrid_post_get = 0; |
31
|
|
|
|
|
|
|
$Nes::Minimal::_mod_perl = 0; |
32
|
|
|
|
|
|
|
$Nes::Minimal::_no_subprocess_env = 0; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$Nes::Minimal::_use_tmp = 0; |
35
|
|
|
|
|
|
|
$Nes::Minimal::_max_upload = 0; |
36
|
|
|
|
|
|
|
$Nes::Minimal::_save_BUFFER = undef; |
37
|
|
|
|
|
|
|
$Nes::Minimal::_save_BUFFER_String = undef; |
38
|
|
|
|
|
|
|
$Nes::Minimal::_ERROR_max_upload = 0; |
39
|
|
|
|
|
|
|
$Nes::Minimal::_ERROR_max_post = 0; |
40
|
|
|
|
|
|
|
#$Nes::Minimal:: = undef; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$Nes::Minimal::VERSION = "1.2902"; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
if (exists ($ENV{'MOD_PERL'}) && (0 == $Nes::Minimal::_mod_perl)) { |
45
|
|
|
|
|
|
|
local $| = 1; |
46
|
|
|
|
|
|
|
my $env_mod_perl = $ENV{'MOD_PERL'}; |
47
|
|
|
|
|
|
|
if ($env_mod_perl =~ m#^mod_perl/1.99#) { # Redhat's almost-but-not-quite ModPerl2.... |
48
|
|
|
|
|
|
|
require Apache::compat; |
49
|
|
|
|
|
|
|
require Nes::Minimal::Misc; |
50
|
|
|
|
|
|
|
require Nes::Minimal::Multipart; |
51
|
|
|
|
|
|
|
$Nes::Minimal::_mod_perl = 1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} elsif (exists ($ENV{MOD_PERL_API_VERSION}) && ($ENV{MOD_PERL_API_VERSION} == 2)) { |
54
|
|
|
|
|
|
|
require Apache2::RequestUtil; |
55
|
|
|
|
|
|
|
require Apache2::RequestIO; |
56
|
|
|
|
|
|
|
require APR::Pool; |
57
|
|
|
|
|
|
|
require Nes::Minimal::Misc; |
58
|
|
|
|
|
|
|
require Nes::Minimal::Multipart; |
59
|
|
|
|
|
|
|
$Nes::Minimal::_mod_perl = 2; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} else { |
62
|
|
|
|
|
|
|
require Apache; |
63
|
|
|
|
|
|
|
require Nes::Minimal::Misc; |
64
|
|
|
|
|
|
|
require Nes::Minimal::Multipart; |
65
|
|
|
|
|
|
|
$Nes::Minimal::_mod_perl = 1; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
binmode STDIN; |
69
|
|
|
|
|
|
|
reset_globals(); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#### |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub import { |
74
|
3
|
|
|
3
|
|
8
|
my $class = shift; |
75
|
3
|
|
|
|
|
13
|
my %flags = map { $_ => 1 } @_; |
|
0
|
|
|
|
|
0
|
|
76
|
3
|
50
|
|
|
|
15
|
if ($flags{':preload'}) { |
77
|
0
|
|
|
|
|
0
|
require Nes::Minimal::Misc; |
78
|
0
|
|
|
|
|
0
|
require Nes::Minimal::Multipart; |
79
|
|
|
|
|
|
|
} |
80
|
3
|
|
|
|
|
3305
|
$Nes::Minimal::_no_subprocess_env = $flags{':no_subprocess_env'}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#### |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub new { |
86
|
1
|
|
|
1
|
0
|
2
|
my $proto = shift; |
87
|
1
|
|
|
|
|
2
|
my $pkg = __PACKAGE__; |
88
|
|
|
|
|
|
|
|
89
|
1
|
50
|
|
|
|
3
|
if ($Nes::Minimal::form_initial_read) { |
90
|
1
|
|
|
|
|
70
|
binmode STDIN; |
91
|
1
|
|
|
|
|
10
|
$Nes::Minimal::_query->_read_form; |
92
|
1
|
|
|
|
|
2
|
$Nes::Minimal::form_initial_read = 0; |
93
|
|
|
|
|
|
|
} |
94
|
1
|
50
|
|
|
|
7
|
if (1 == $Nes::Minimal::_mod_perl) { |
|
|
50
|
|
|
|
|
|
95
|
0
|
|
|
|
|
0
|
Apache->request->register_cleanup(\&Nes::Minimal::reset_globals); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} elsif (2 == $Nes::Minimal::_mod_perl) { |
98
|
0
|
|
|
|
|
0
|
Apache2::RequestUtil->request->pool->cleanup_register(\&Nes::Minimal::reset_globals); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
4
|
return $Nes::Minimal::_query; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#### |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub reset_globals { |
107
|
3
|
|
|
3
|
0
|
6
|
$Nes::Minimal::form_initial_read = 1; |
108
|
3
|
|
|
|
|
4
|
$Nes::Minimal::_allow_hybrid_post_get = 0; |
109
|
|
|
|
|
|
|
|
110
|
3
|
|
|
|
|
6
|
$Nes::Minimal::_save_BUFFER = undef; |
111
|
3
|
|
|
|
|
5
|
$Nes::Minimal::_save_BUFFER_String = undef; |
112
|
3
|
|
|
|
|
4
|
$Nes::Minimal::_use_tmp = 0; |
113
|
3
|
|
|
|
|
4
|
$Nes::Minimal::_max_upload = 0; |
114
|
3
|
|
|
|
|
5
|
$Nes::Minimal::_ERROR_max_upload = 0; |
115
|
3
|
|
|
|
|
5
|
$Nes::Minimal::_ERROR_max_post = 0; |
116
|
3
|
|
|
|
|
6
|
$Nes::Minimal::_sub_filter = undef; |
117
|
|
|
|
|
|
|
|
118
|
3
|
|
|
|
|
7
|
$Nes::Minimal::_query = {}; |
119
|
3
|
|
|
|
|
4
|
bless $Nes::Minimal::_query; |
120
|
3
|
|
|
|
|
8
|
my $pkg = __PACKAGE__; |
121
|
|
|
|
|
|
|
|
122
|
3
|
|
|
|
|
5
|
$Nes::Minimal::_BUFFER = undef; |
123
|
3
|
|
|
|
|
10
|
max_read_size(1000000); |
124
|
3
|
|
|
|
|
9
|
$Nes::Minimal::_query->{$pkg}->{'field_names'} = []; |
125
|
3
|
|
|
|
|
8
|
$Nes::Minimal::_query->{$pkg}->{'field'} = {}; |
126
|
3
|
|
|
|
|
8
|
$Nes::Minimal::_query->{$pkg}->{'form_truncated'} = undef; |
127
|
|
|
|
|
|
|
|
128
|
3
|
|
|
|
|
5
|
$Nes::Minimal::_query->{$pkg}->{'from_file'} = {}; |
129
|
|
|
|
|
|
|
|
130
|
3
|
|
|
|
|
8
|
return 1; # Keeps mod_perl from complaining |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# For backward compatibility |
134
|
0
|
|
|
0
|
|
0
|
sub _reset_globals { reset_globals; } |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
### |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub subprocess_env { |
139
|
0
|
0
|
|
0
|
0
|
0
|
if (2 == $Nes::Minimal::_mod_perl) { |
140
|
0
|
|
|
|
|
0
|
Apache2::RequestUtil->request->subprocess_env; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
### |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub allow_hybrid_post_get { |
147
|
1
|
50
|
|
1
|
0
|
4
|
if (@_ > 0) { |
148
|
1
|
|
|
|
|
4
|
$Nes::Minimal::_allow_hybrid_post_get = $_[0]; |
149
|
|
|
|
|
|
|
} else { |
150
|
0
|
|
|
|
|
0
|
return $Nes::Minimal::_allow_hybrid_post_get; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub use_tmp { |
155
|
1
|
50
|
|
1
|
0
|
4
|
if (@_ > 0) { |
156
|
1
|
|
|
|
|
3
|
$Nes::Minimal::_use_tmp = $_[0]; |
157
|
|
|
|
|
|
|
} else { |
158
|
0
|
|
|
|
|
0
|
return $$Nes::Minimal::_use_tmp; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub save_buffer { |
163
|
0
|
0
|
|
0
|
0
|
0
|
if (@_ > 0) { |
164
|
0
|
|
|
|
|
0
|
$Nes::Minimal::_save_BUFFER = $_[0]; |
165
|
|
|
|
|
|
|
} else { |
166
|
0
|
|
|
|
|
0
|
return $$Nes::Minimal::_save_BUFFER; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub sub_filter { |
171
|
0
|
0
|
|
0
|
0
|
0
|
if (@_ > 0) { |
172
|
0
|
|
|
|
|
0
|
$Nes::Minimal::_sub_filter = $_[0]; |
173
|
|
|
|
|
|
|
} else { |
174
|
0
|
|
|
|
|
0
|
return $Nes::Minimal::_sub_filter; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub max_upload { |
179
|
1
|
50
|
|
1
|
0
|
3
|
if (@_ > 0) { |
180
|
1
|
|
|
|
|
3
|
$Nes::Minimal::_max_upload = $_[0]; |
181
|
|
|
|
|
|
|
} else { |
182
|
0
|
|
|
|
|
0
|
return $$Nes::Minimal::_max_upload; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
### |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub delete_all { |
191
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
192
|
0
|
|
|
|
|
0
|
my $pkg = __PACKAGE__; |
193
|
0
|
|
|
|
|
0
|
$Nes::Minimal::_query->{$pkg}->{'field_names'} = []; |
194
|
0
|
|
|
|
|
0
|
$Nes::Minimal::_query->{$pkg}->{'field'} = {}; |
195
|
0
|
|
|
|
|
0
|
$Nes::Minimal::_query->{$pkg}->{'from_file'} = {}; |
196
|
0
|
|
|
|
|
0
|
return; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
#### |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub delete { |
202
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
203
|
0
|
|
|
|
|
0
|
my $pkg = __PACKAGE__; |
204
|
0
|
|
|
|
|
0
|
my $vars = $self->{$pkg}; |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
0
|
my @names_list = @_; |
207
|
0
|
|
|
|
|
0
|
my %tagged_names = map { $_ => 1 } @names_list; |
|
0
|
|
|
|
|
0
|
|
208
|
0
|
|
|
|
|
0
|
my @parm_names = @{$vars->{'field_names'}}; |
|
0
|
|
|
|
|
0
|
|
209
|
0
|
|
|
|
|
0
|
my $fields = []; |
210
|
0
|
|
|
|
|
0
|
my $data = $vars->{'field'}; |
211
|
0
|
|
|
|
|
0
|
foreach my $parm (@parm_names) { |
212
|
0
|
0
|
|
|
|
0
|
if ($tagged_names{$parm}) { |
213
|
0
|
|
|
|
|
0
|
delete $data->{$parm}; |
214
|
|
|
|
|
|
|
} else { |
215
|
0
|
|
|
|
|
0
|
push (@$fields, $parm); |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
} |
218
|
0
|
|
|
|
|
0
|
$vars->{'field_names'} = $fields; |
219
|
0
|
|
|
|
|
0
|
return; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
#### |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub upload { |
225
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
226
|
0
|
|
|
|
|
0
|
my $pkg = __PACKAGE__; |
227
|
0
|
|
|
|
|
0
|
my ($field_name) = @_; |
228
|
0
|
|
|
|
|
0
|
my $vars = $self->{$pkg}; |
229
|
|
|
|
|
|
|
|
230
|
0
|
0
|
|
|
|
0
|
return if !defined($vars->{'field'}->{$field_name}); |
231
|
0
|
0
|
|
|
|
0
|
return $vars->{'from_file'}->{'fh'}->{$field_name} if exists $vars->{'from_file'}->{'fh'}->{$field_name}; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# if not tmp file, the data is in var in old style =< 1.29 |
234
|
0
|
0
|
|
|
|
0
|
if ( !$vars->{'from_file'}->{$field_name} ) { |
235
|
0
|
|
|
|
|
0
|
require IO::String; |
236
|
0
|
|
|
|
|
0
|
$vars->{'from_file'}->{'fh'}->{$field_name} = IO::String->new($vars->{'field'}->{$field_name}->{'value'}[0]); |
237
|
|
|
|
|
|
|
} else { |
238
|
0
|
|
|
|
|
0
|
$vars->{'from_file'}->{'fh'}->{$field_name} = $vars->{'from_file'}->{$field_name}; |
239
|
|
|
|
|
|
|
} |
240
|
0
|
|
|
|
|
0
|
binmode $vars->{'from_file'}->{'fh'}->{$field_name}; |
241
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
0
|
return $vars->{'from_file'}->{'fh'}->{$field_name}; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub upload_is_tmp { |
246
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
247
|
0
|
|
|
|
|
0
|
my $pkg = __PACKAGE__; |
248
|
0
|
|
|
|
|
0
|
my ($field_name) = @_; |
249
|
0
|
|
|
|
|
0
|
my $vars = $self->{$pkg}; |
250
|
|
|
|
|
|
|
|
251
|
0
|
0
|
|
|
|
0
|
return 1 if $vars->{'from_file'}->{$field_name}; |
252
|
0
|
|
|
|
|
0
|
return 0; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub upload_max_size { |
256
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
257
|
0
|
|
|
|
|
0
|
my $pkg = __PACKAGE__; |
258
|
0
|
|
|
|
|
0
|
my $vars = $self->{$pkg}; |
259
|
|
|
|
|
|
|
|
260
|
0
|
0
|
|
|
|
0
|
return 1 if $Nes::Minimal::_ERROR_max_upload; |
261
|
0
|
|
|
|
|
0
|
return 0; |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub post_max_size { |
265
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
266
|
0
|
|
|
|
|
0
|
my $pkg = __PACKAGE__; |
267
|
0
|
|
|
|
|
0
|
my $vars = $self->{$pkg}; |
268
|
|
|
|
|
|
|
|
269
|
0
|
0
|
|
|
|
0
|
return 1 if $Nes::Minimal::_ERROR_max_post; |
270
|
0
|
|
|
|
|
0
|
return 0; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
#### |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
sub param { |
276
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
277
|
1
|
|
|
|
|
3
|
my $pkg = __PACKAGE__; |
278
|
|
|
|
|
|
|
|
279
|
1
|
50
|
33
|
|
|
10
|
if (1 < @_) { |
|
|
50
|
|
|
|
|
|
280
|
0
|
|
|
|
|
0
|
my $n_parms = @_; |
281
|
0
|
0
|
|
|
|
0
|
if (($n_parms % 2) == 1) { |
282
|
0
|
|
|
|
|
0
|
require Carp; |
283
|
0
|
|
|
|
|
0
|
Carp::confess("${pkg}::param() - Odd number of parameters (other than 1) passed"); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
0
|
|
|
|
|
0
|
my $parms = { @_ }; |
287
|
0
|
|
|
|
|
0
|
require Nes::Minimal::Misc; |
288
|
0
|
|
|
|
|
0
|
$self->_internal_set($parms); |
289
|
0
|
|
|
|
|
0
|
return; |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
} elsif ((1 == @_) and (ref ($_[0]) eq 'HASH')) { |
292
|
0
|
|
|
|
|
0
|
my $parms = shift; |
293
|
0
|
|
|
|
|
0
|
require Nes::Minimal::Misc; |
294
|
0
|
|
|
|
|
0
|
$self->_internal_set($parms); |
295
|
0
|
|
|
|
|
0
|
return; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
# Requesting parameter values |
299
|
|
|
|
|
|
|
|
300
|
1
|
|
|
|
|
3
|
my $vars = $self->{$pkg}; |
301
|
1
|
|
|
|
|
2
|
my @result = (); |
302
|
1
|
50
|
|
|
|
5
|
if ($#_ == -1) { |
303
|
1
|
|
|
|
|
2
|
@result = @{$vars->{'field_names'}}; |
|
1
|
|
|
|
|
3
|
|
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
} else { |
306
|
0
|
|
|
|
|
0
|
my ($fname) = @_; |
307
|
0
|
0
|
|
|
|
0
|
if (defined($vars->{'field'}->{$fname})) { |
308
|
0
|
|
|
|
|
0
|
@result = @{$vars->{'field'}->{$fname}->{'value'}}; |
|
0
|
|
|
|
|
0
|
|
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
1
|
50
|
|
|
|
9
|
if (wantarray) { return @result; } |
|
1
|
0
|
|
|
|
5
|
|
313
|
0
|
|
|
|
|
0
|
elsif ($#result > -1) { return $result[0]; } |
314
|
0
|
|
|
|
|
0
|
return; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
#### |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
sub raw { |
320
|
0
|
0
|
|
0
|
0
|
0
|
return if (! defined $Nes::Minimal::_BUFFER); |
321
|
0
|
|
|
|
|
0
|
return $$Nes::Minimal::_BUFFER; |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub raw_saved { |
325
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
326
|
0
|
|
|
|
|
0
|
my ( $buffer, $read_length ) = @_; |
327
|
|
|
|
|
|
|
|
328
|
0
|
|
0
|
|
|
0
|
my $fh = $Nes::Minimal::_BUFFER_saved || $Nes::Minimal::_save_BUFFER_String; |
329
|
|
|
|
|
|
|
|
330
|
0
|
0
|
|
|
|
0
|
return if !$fh; |
331
|
0
|
|
|
|
|
0
|
return read($fh, $$buffer, $read_length); |
332
|
|
|
|
|
|
|
} |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
#### |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub truncated { |
337
|
0
|
|
|
0
|
0
|
0
|
my $pkg = __PACKAGE__; |
338
|
0
|
|
|
|
|
0
|
shift->{$pkg}->{'form_truncated'}; |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
#### |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
sub max_read_size { |
344
|
4
|
|
|
4
|
0
|
8
|
my $pkg = __PACKAGE__; |
345
|
4
|
|
|
|
|
47
|
$Nes::Minimal::_query->{$pkg}->{'max_buffer'} = $_[0]; |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
#### |
349
|
|
|
|
|
|
|
# Wrapper for form reading for GET, HEAD and POST methods |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
sub _read_form { |
352
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
353
|
|
|
|
|
|
|
|
354
|
1
|
|
|
|
|
3
|
my $pkg = __PACKAGE__; |
355
|
1
|
|
|
|
|
2
|
my $vars = $self->{$pkg}; |
356
|
|
|
|
|
|
|
|
357
|
1
|
|
|
|
|
3
|
$vars->{'field'} = {}; |
358
|
1
|
|
|
|
|
3
|
$vars->{'field_names'} = []; |
359
|
|
|
|
|
|
|
|
360
|
1
|
|
|
|
|
3
|
my $req_method=$ENV{"REQUEST_METHOD"}; |
361
|
1
|
50
|
33
|
|
|
5
|
if ((2 == $Nes::Minimal::_mod_perl) and (not defined $req_method)) { |
362
|
0
|
|
|
|
|
0
|
$req_method = Apache2::RequestUtil->request->method; |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
|
365
|
1
|
50
|
|
|
|
4
|
if (! defined $req_method) { |
366
|
|
|
|
|
|
|
# todo, no funciona cuando hacemos ./script.cgi, revisar |
367
|
|
|
|
|
|
|
# my $input = ; |
368
|
|
|
|
|
|
|
# $input = '' if (! defined $input); |
369
|
|
|
|
|
|
|
# $ENV{'QUERY_STRING'} = $input; |
370
|
|
|
|
|
|
|
# chomp $ENV{'QUERY_STRING'}; |
371
|
|
|
|
|
|
|
# $self->_read_get; |
372
|
|
|
|
|
|
|
# --------------------------------------------------------- |
373
|
1
|
|
|
|
|
7
|
return; |
374
|
|
|
|
|
|
|
} |
375
|
0
|
0
|
0
|
|
|
|
if ($req_method eq 'POST') { |
|
|
0
|
|
|
|
|
|
376
|
0
|
|
|
|
|
|
$self->_read_post; |
377
|
0
|
0
|
|
|
|
|
if ($Nes::Minimal::_allow_hybrid_post_get) { |
378
|
0
|
|
|
|
|
|
$self->_read_get; |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
} elsif (($req_method eq 'GET') || ($req_method eq 'HEAD')) { |
381
|
0
|
|
|
|
|
|
$self->_read_get; |
382
|
|
|
|
|
|
|
} else { |
383
|
0
|
|
|
|
|
|
my $package = __PACKAGE__; |
384
|
0
|
|
|
|
|
|
require Carp; |
385
|
0
|
|
|
|
|
|
Carp::carp($package . " - Unsupported HTTP request method of '$req_method'. Treating as 'GET'"); |
386
|
0
|
|
|
|
|
|
$self->_read_get; |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
#### |
391
|
|
|
|
|
|
|
# Performs form reading for POST method |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub _read_post { |
394
|
0
|
|
|
0
|
|
|
my $self = shift; |
395
|
0
|
|
|
|
|
|
my $pkg = __PACKAGE__; |
396
|
0
|
|
|
|
|
|
my $vars = $self->{$pkg}; |
397
|
|
|
|
|
|
|
|
398
|
0
|
|
|
|
|
|
my $r; |
399
|
0
|
0
|
|
|
|
|
if (2 == $Nes::Minimal::_mod_perl) { |
400
|
0
|
|
|
|
|
|
$r = Apache2::RequestUtil->request; |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
|
my $read_length = $vars->{'max_buffer'}; |
404
|
0
|
|
|
|
|
|
my $clen = $ENV{'CONTENT_LENGTH'}; |
405
|
0
|
0
|
0
|
|
|
|
if ((2 == $Nes::Minimal::_mod_perl) and (not defined $clen)) { |
406
|
0
|
|
|
|
|
|
$clen = $r->headers_in->get('Content-Length'); |
407
|
|
|
|
|
|
|
} |
408
|
0
|
0
|
|
|
|
|
if ($clen < $read_length) { |
409
|
0
|
|
|
|
|
|
$read_length = $clen; |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
0
|
0
|
|
|
|
|
my $content_type = defined($ENV{'CONTENT_TYPE'}) ? $ENV{'CONTENT_TYPE'} : ''; |
413
|
0
|
0
|
0
|
|
|
|
if ((!$content_type) and (2 == $Nes::Minimal::_mod_perl)) { |
414
|
0
|
|
|
|
|
|
$content_type = $r->headers_in->get('Content-Type'); |
415
|
|
|
|
|
|
|
} |
416
|
|
|
|
|
|
|
|
417
|
0
|
0
|
|
|
|
|
my $bdry = $1 if $content_type =~ m/^multipart\/form-data; boundary=(.*)$/i; |
418
|
|
|
|
|
|
|
|
419
|
0
|
|
|
|
|
|
my $buffer = ''; |
420
|
0
|
|
|
|
|
|
my $read_bytes = 0; |
421
|
|
|
|
|
|
|
|
422
|
0
|
0
|
0
|
|
|
|
if ( ($bdry && $Nes::Minimal::_sub_filter) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
423
|
|
|
|
|
|
|
($bdry && $ENV{'CONTENT_LENGTH'} > $Nes::Minimal::_use_tmp && $Nes::Minimal::_use_tmp) ) { |
424
|
|
|
|
|
|
|
|
425
|
0
|
0
|
|
|
|
|
if ($ENV{'CONTENT_LENGTH'} > $Nes::Minimal::_max_upload) { |
426
|
0
|
|
|
|
|
|
$Nes::Minimal::_ERROR_max_upload = 1; |
427
|
0
|
|
|
|
|
|
require Carp; |
428
|
0
|
|
|
|
|
|
Carp::carp($pkg . " The POST is greater than max_upload: $ENV{'CONTENT_LENGTH'} > $Nes::Minimal::_max_upload"); |
429
|
0
|
|
|
|
|
|
return; |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
|
433
|
0
|
0
|
|
|
|
|
if (2 == $Nes::Minimal::_mod_perl) { |
434
|
0
|
|
|
|
|
|
$read_bytes = $self->_read_post_bdry(\$buffer,$bdry,$r); |
435
|
|
|
|
|
|
|
} else { |
436
|
0
|
|
|
|
|
|
$read_bytes = $self->_read_post_bdry(\$buffer,$bdry); |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
} else { |
440
|
|
|
|
|
|
|
|
441
|
0
|
0
|
|
|
|
|
if ($ENV{'CONTENT_LENGTH'} > $vars->{'max_buffer'}) { |
442
|
0
|
|
|
|
|
|
$Nes::Minimal::_ERROR_max_post = 1; |
443
|
0
|
|
|
|
|
|
require Carp; |
444
|
0
|
|
|
|
|
|
Carp::carp($pkg . " The POST is greater than max_post: $ENV{'CONTENT_LENGTH'} > $vars->{'max_buffer'}"); |
445
|
0
|
|
|
|
|
|
return; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
0
|
0
|
|
|
|
|
if ($read_length) { |
449
|
0
|
0
|
|
|
|
|
if (2 == $Nes::Minimal::_mod_perl) { |
450
|
0
|
|
|
|
|
|
$read_bytes = $r->read($buffer,$read_length,0); |
451
|
|
|
|
|
|
|
} else { |
452
|
0
|
|
|
|
|
|
$read_bytes = read(STDIN, $buffer, $read_length,0); |
453
|
|
|
|
|
|
|
} |
454
|
0
|
0
|
|
|
|
|
$self->filter_data(\$buffer) if $Nes::Minimal::_sub_filter; |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
} |
458
|
0
|
|
|
|
|
|
$Nes::Minimal::_BUFFER = \$buffer; |
459
|
0
|
0
|
|
|
|
|
$vars->{'form_truncated'} = ($read_bytes < $clen) ? 1 : 0; |
460
|
|
|
|
|
|
|
|
461
|
0
|
0
|
|
|
|
|
if ( !defined $Nes::Minimal::_BUFFER_saved ) { |
462
|
0
|
|
|
|
|
|
require IO::String; |
463
|
0
|
|
|
|
|
|
$Nes::Minimal::_save_BUFFER_String = IO::String->new($Nes::Minimal::_BUFFER); |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
# Boundaries are supposed to consist of only the following |
467
|
|
|
|
|
|
|
# (1-70 of them, not ending in ' ') A-Za-z0-9 '()+,_-./:=? |
468
|
|
|
|
|
|
|
|
469
|
0
|
0
|
|
|
|
|
if ( $content_type =~ m/^multipart\/form-data; boundary=(.*)$/i ) { |
470
|
0
|
|
|
|
|
|
my $bdry = $1; |
471
|
0
|
|
|
|
|
|
require Nes::Minimal::Multipart; |
472
|
0
|
|
|
|
|
|
$self->_burst_multipart_buffer ($buffer,$bdry); |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
} else { |
475
|
0
|
|
|
|
|
|
$self->_burst_URL_encoded_buffer($buffer,'[;&]'); |
476
|
|
|
|
|
|
|
} |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
sub _read { |
481
|
0
|
|
|
0
|
|
|
my $self = shift; |
482
|
0
|
|
|
|
|
|
my ( $buffer, $read_length, $r ) = @_; |
483
|
|
|
|
|
|
|
|
484
|
0
|
0
|
|
|
|
|
if ($r) { |
485
|
0
|
|
|
|
|
|
return $r->read($$buffer, $read_length); |
486
|
|
|
|
|
|
|
} else { |
487
|
0
|
|
|
|
|
|
return read(STDIN, $$buffer, $read_length); |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
} |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
#### |
493
|
|
|
|
|
|
|
# Use tmp file from big POST |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
sub _read_post_bdry { |
496
|
0
|
|
|
0
|
|
|
my $self = shift; |
497
|
0
|
|
|
|
|
|
my ( $buffer, $bdry, $r ) = @_; |
498
|
0
|
|
|
|
|
|
my $pkg = __PACKAGE__; |
499
|
0
|
|
|
|
|
|
my $vars = $self->{$pkg}; |
500
|
|
|
|
|
|
|
|
501
|
0
|
|
0
|
|
|
|
my $use_tmp = $ENV{'CONTENT_LENGTH'} > $Nes::Minimal::_use_tmp && $Nes::Minimal::_use_tmp; |
502
|
0
|
|
|
|
|
|
my $tmp_fh; |
503
|
0
|
|
|
|
|
|
my $size_buffer = 8192; |
504
|
0
|
|
|
|
|
|
my $rbuffer; |
505
|
|
|
|
|
|
|
my $bbuffer; |
506
|
0
|
|
|
|
|
|
my $buffer_fh; |
507
|
0
|
|
|
|
|
|
my $data; |
508
|
0
|
|
|
|
|
|
my $read_bytes = 0; |
509
|
0
|
|
|
|
|
|
my $field_name = ''; |
510
|
0
|
|
|
|
|
|
my $file_name = ''; |
511
|
0
|
|
|
|
|
|
my $content_type = ''; |
512
|
|
|
|
|
|
|
|
513
|
0
|
0
|
|
|
|
|
if ( $Nes::Minimal::_save_BUFFER ) { |
514
|
0
|
|
|
|
|
|
require IO::File; |
515
|
0
|
|
|
|
|
|
$buffer_fh = IO::File->new_tmpfile; |
516
|
0
|
|
|
|
|
|
$Nes::Minimal::_BUFFER_saved = $buffer_fh; |
517
|
|
|
|
|
|
|
} |
518
|
|
|
|
|
|
|
|
519
|
0
|
|
0
|
|
|
|
while ( (my $readb = $self->_read(\$rbuffer, $size_buffer, $r)) || $data ) { |
520
|
0
|
|
|
|
|
|
$read_bytes += $readb; |
521
|
|
|
|
|
|
|
|
522
|
0
|
0
|
|
|
|
|
if ($read_bytes > $Nes::Minimal::_max_upload) { |
523
|
0
|
|
|
|
|
|
$Nes::Minimal::_ERROR_max_upload = 1; |
524
|
0
|
|
|
|
|
|
require Carp; |
525
|
0
|
|
|
|
|
|
Carp::carp($pkg . " - The POST is greater than max_upload: $ENV{'CONTENT_LENGTH'} > $Nes::Minimal::_max_upload"); |
526
|
0
|
|
|
|
|
|
last; |
527
|
|
|
|
|
|
|
} |
528
|
|
|
|
|
|
|
|
529
|
0
|
|
|
|
|
|
$data .= $rbuffer; |
530
|
0
|
0
|
|
|
|
|
if ( $data =~ /^(--\Q$bdry\E\015\012Content-Disposition:[^\015\012]* name\=\"([^\"]*)\"(?:[^\015\012]* filename\=\"([^\"]*)"[^\015\012]*|[^\015\012]*)\015\012([^\015\012]*)\015\012)/si ) { |
|
|
0
|
|
|
|
|
|
531
|
0
|
|
|
|
|
|
$field_name = $2; |
532
|
0
|
|
|
|
|
|
$file_name = $3; |
533
|
0
|
|
|
|
|
|
$content_type = $4; |
534
|
0
|
|
|
|
|
|
$$buffer .= $1; |
535
|
0
|
|
|
|
|
|
$data = $'; |
536
|
0
|
0
|
|
|
|
|
print $buffer_fh $1 if $buffer_fh; |
537
|
0
|
0
|
0
|
|
|
|
if ( $file_name && $use_tmp ) { |
538
|
0
|
|
|
|
|
|
$data =~ s/([^\015\012]*\015\012)//si; |
539
|
0
|
|
|
|
|
|
$$buffer .= $1; |
540
|
0
|
0
|
|
|
|
|
print $buffer_fh $1 if $buffer_fh; |
541
|
0
|
|
|
|
|
|
require IO::File; |
542
|
0
|
|
|
|
|
|
$tmp_fh = IO::File->new_tmpfile; |
543
|
0
|
|
|
|
|
|
binmode $tmp_fh; |
544
|
0
|
|
|
|
|
|
$vars->{'from_file'}->{$field_name} = $tmp_fh; |
545
|
|
|
|
|
|
|
} |
546
|
0
|
|
|
|
|
|
next; |
547
|
|
|
|
|
|
|
} elsif ( $data =~ /^(\015\012--\Q$bdry\E--.*)/si ) { |
548
|
0
|
|
|
|
|
|
$$buffer .= $1; |
549
|
0
|
0
|
|
|
|
|
print $buffer_fh $1 if $buffer_fh; |
550
|
0
|
|
|
|
|
|
$data = ''; |
551
|
0
|
|
|
|
|
|
last; |
552
|
|
|
|
|
|
|
} |
553
|
|
|
|
|
|
|
|
554
|
0
|
0
|
|
|
|
|
if ( $data =~ m/(\015\012)(--\Q$bdry\E\015\012)/ ) { |
555
|
0
|
|
|
|
|
|
$data = $2.$'; |
556
|
0
|
|
|
|
|
|
my $sdata = $`; |
557
|
0
|
0
|
0
|
|
|
|
$self->filter_data(\$sdata) if $content_type =~ m/Content-Type: text/i || !$content_type; |
558
|
0
|
0
|
0
|
|
|
|
if ( $file_name && $use_tmp ) { |
559
|
0
|
|
|
|
|
|
$$buffer .= "$file_name\015\012"; |
560
|
0
|
|
|
|
|
|
print $tmp_fh $sdata; |
561
|
0
|
0
|
|
|
|
|
print $buffer_fh $sdata."\015\012" if $buffer_fh; |
562
|
0
|
|
|
|
|
|
$file_name = ''; |
563
|
0
|
|
|
|
|
|
$content_type = ''; |
564
|
0
|
|
|
|
|
|
seek($tmp_fh, 0, 0); |
565
|
|
|
|
|
|
|
} else { |
566
|
0
|
|
|
|
|
|
$$buffer .= $sdata."\015\012"; |
567
|
0
|
0
|
|
|
|
|
print $buffer_fh $sdata."\015\012" if $buffer_fh; |
568
|
|
|
|
|
|
|
} |
569
|
|
|
|
|
|
|
} else { |
570
|
0
|
0
|
0
|
|
|
|
$self->filter_data(\$data) if $content_type =~ m/Content-Type: text/i || !$content_type; |
571
|
0
|
0
|
0
|
|
|
|
$$buffer .= $data if !$file_name || !$use_tmp; |
572
|
0
|
0
|
0
|
|
|
|
print $tmp_fh $data if $file_name && $use_tmp; |
573
|
0
|
0
|
|
|
|
|
print $buffer_fh $data if $buffer_fh; |
574
|
0
|
|
|
|
|
|
$data = ''; |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
} |
578
|
|
|
|
|
|
|
|
579
|
0
|
0
|
|
|
|
|
seek($buffer_fh, 0, 0) if $buffer_fh; |
580
|
0
|
|
|
|
|
|
return $read_bytes; |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
} |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
sub filter_data { |
585
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
586
|
0
|
|
|
|
|
|
my ($data) = @_; |
587
|
|
|
|
|
|
|
|
588
|
0
|
0
|
|
|
|
|
return if !$Nes::Minimal::_sub_filter; |
589
|
|
|
|
|
|
|
|
590
|
0
|
|
|
|
|
|
$Nes::Minimal::_sub_filter->($data); |
591
|
|
|
|
|
|
|
|
592
|
0
|
|
|
|
|
|
return; |
593
|
|
|
|
|
|
|
} |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
#### |
596
|
|
|
|
|
|
|
# GET and HEAD |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
sub _read_get { |
599
|
0
|
|
|
0
|
|
|
my $self = shift; |
600
|
|
|
|
|
|
|
|
601
|
0
|
|
|
|
|
|
my $buffer = ''; |
602
|
0
|
|
|
|
|
|
my $req_method = $ENV{'REQUEST_METHOD'}; |
603
|
0
|
0
|
|
|
|
|
if (1 == $Nes::Minimal::_mod_perl) { |
|
|
0
|
|
|
|
|
|
604
|
0
|
|
|
|
|
|
$buffer = Apache->request->args; |
605
|
|
|
|
|
|
|
} elsif (2 == $Nes::Minimal::_mod_perl) { |
606
|
0
|
|
|
|
|
|
my $r = Apache2::RequestUtil->request; |
607
|
0
|
|
|
|
|
|
$buffer = $r->args; |
608
|
0
|
|
|
|
|
|
$r->discard_request_body(); |
609
|
0
|
0
|
0
|
|
|
|
unless (exists($ENV{'REQUEST_METHOD'}) || $Nes::Minimal::_no_subprocess_env) { |
610
|
0
|
|
|
|
|
|
$r->subprocess_env; |
611
|
|
|
|
|
|
|
} |
612
|
0
|
0
|
|
|
|
|
$req_method = $r->method unless ($req_method); |
613
|
|
|
|
|
|
|
} else { |
614
|
0
|
0
|
|
|
|
|
$buffer = $ENV{'QUERY_STRING'} if (defined $ENV{'QUERY_STRING'}); |
615
|
|
|
|
|
|
|
} |
616
|
0
|
0
|
|
|
|
|
if ($req_method ne 'POST') { |
617
|
0
|
|
|
|
|
|
$Nes::Minimal::_BUFFER = \$buffer; |
618
|
|
|
|
|
|
|
} |
619
|
0
|
|
|
|
|
|
$self->_burst_URL_encoded_buffer($buffer,'[;&]'); |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
#### |
623
|
|
|
|
|
|
|
# Bursts URL encoded buffers |
624
|
|
|
|
|
|
|
# $buffer - data to be burst |
625
|
|
|
|
|
|
|
# $spliton - split pattern |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
sub _burst_URL_encoded_buffer { |
628
|
0
|
|
|
0
|
|
|
my $self = shift; |
629
|
0
|
|
|
|
|
|
my $pkg = __PACKAGE__; |
630
|
0
|
|
|
|
|
|
my $vars = $self->{$pkg}; |
631
|
|
|
|
|
|
|
|
632
|
0
|
|
|
|
|
|
my ($buffer,$spliton)=@_; |
633
|
|
|
|
|
|
|
|
634
|
0
|
|
|
|
|
|
my ($mime_type) = "text/plain"; |
635
|
0
|
|
|
|
|
|
my ($filename) = ""; |
636
|
|
|
|
|
|
|
|
637
|
0
|
0
|
|
|
|
|
my @pairs = $buffer ? split(/$spliton/, $buffer) : (); |
638
|
|
|
|
|
|
|
|
639
|
0
|
|
|
|
|
|
foreach my $pair (@pairs) { |
640
|
0
|
|
|
|
|
|
my ($name, $data) = split(/=/,$pair,2); |
641
|
|
|
|
|
|
|
|
642
|
0
|
0
|
|
|
|
|
$name = '' unless (defined $name); |
643
|
0
|
|
|
|
|
|
$name =~ s/\+/ /gs; |
644
|
0
|
|
|
|
|
|
$name =~ s/%(?:([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/ |
645
|
0
|
0
|
|
|
|
|
defined($1)? chr hex($1) : _utf8_chr(hex($2))/ge; |
646
|
0
|
0
|
|
|
|
|
$data = '' unless (defined $data); |
647
|
0
|
|
|
|
|
|
$data =~ s/\+/ /gs; |
648
|
0
|
|
|
|
|
|
$data =~ s/%(?:([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/ |
649
|
0
|
0
|
|
|
|
|
defined($1)? chr hex($1) : _utf8_chr(hex($2))/ge; |
650
|
|
|
|
|
|
|
|
651
|
0
|
0
|
|
|
|
|
if (! defined ($vars->{'field'}->{$name}->{'count'})) { |
652
|
0
|
|
|
|
|
|
push (@{$vars->{'field_names'}},$name); |
|
0
|
|
|
|
|
|
|
653
|
0
|
|
|
|
|
|
$vars->{'field'}->{$name}->{'count'} = 0; |
654
|
|
|
|
|
|
|
} |
655
|
0
|
|
|
|
|
|
my $record = $vars->{'field'}->{$name}; |
656
|
0
|
|
|
|
|
|
my $f_count = $record->{'count'}; |
657
|
0
|
|
|
|
|
|
$record->{'count'}++; |
658
|
0
|
|
|
|
|
|
$record->{'value'}->[$f_count] = $data; |
659
|
0
|
|
|
|
|
|
$record->{'filename'}->[$f_count] = $filename; |
660
|
0
|
|
|
|
|
|
$record->{'mime_type'}->[$f_count] = $mime_type; |
661
|
|
|
|
|
|
|
} |
662
|
|
|
|
|
|
|
} |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
#### |
665
|
|
|
|
|
|
|
# |
666
|
|
|
|
|
|
|
# _utf8_chr() taken from Nes::Util |
667
|
|
|
|
|
|
|
# Copyright 1995-1998, Lincoln D. Stein. All rights reserved. |
668
|
|
|
|
|
|
|
sub _utf8_chr { |
669
|
0
|
|
|
0
|
|
|
my $c = shift(@_); |
670
|
0
|
0
|
|
|
|
|
return chr($c) if $] >= 5.006; |
671
|
|
|
|
|
|
|
|
672
|
0
|
0
|
|
|
|
|
if ($c < 0x80) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
673
|
0
|
|
|
|
|
|
return sprintf("%c", $c); |
674
|
|
|
|
|
|
|
} elsif ($c < 0x800) { |
675
|
0
|
|
|
|
|
|
return sprintf("%c%c", 0xc0 | ($c >> 6), 0x80 | ($c & 0x3f)); |
676
|
|
|
|
|
|
|
} elsif ($c < 0x10000) { |
677
|
0
|
|
|
|
|
|
return sprintf("%c%c%c", |
678
|
|
|
|
|
|
|
0xe0 | ($c >> 12), |
679
|
|
|
|
|
|
|
0x80 | (($c >> 6) & 0x3f), |
680
|
|
|
|
|
|
|
0x80 | ( $c & 0x3f)); |
681
|
|
|
|
|
|
|
} elsif ($c < 0x200000) { |
682
|
0
|
|
|
|
|
|
return sprintf("%c%c%c%c", |
683
|
|
|
|
|
|
|
0xf0 | ($c >> 18), |
684
|
|
|
|
|
|
|
0x80 | (($c >> 12) & 0x3f), |
685
|
|
|
|
|
|
|
0x80 | (($c >> 6) & 0x3f), |
686
|
|
|
|
|
|
|
0x80 | ( $c & 0x3f)); |
687
|
|
|
|
|
|
|
} elsif ($c < 0x4000000) { |
688
|
0
|
|
|
|
|
|
return sprintf("%c%c%c%c%c", |
689
|
|
|
|
|
|
|
0xf8 | ($c >> 24), |
690
|
|
|
|
|
|
|
0x80 | (($c >> 18) & 0x3f), |
691
|
|
|
|
|
|
|
0x80 | (($c >> 12) & 0x3f), |
692
|
|
|
|
|
|
|
0x80 | (($c >> 6) & 0x3f), |
693
|
|
|
|
|
|
|
0x80 | ( $c & 0x3f)); |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
} elsif ($c < 0x80000000) { |
696
|
0
|
|
|
|
|
|
return sprintf("%c%c%c%c%c%c", |
697
|
|
|
|
|
|
|
0xfc | ($c >> 30), |
698
|
|
|
|
|
|
|
0x80 | (($c >> 24) & 0x3f), |
699
|
|
|
|
|
|
|
0x80 | (($c >> 18) & 0x3f), |
700
|
|
|
|
|
|
|
0x80 | (($c >> 12) & 0x3f), |
701
|
|
|
|
|
|
|
0x80 | (($c >> 6) & 0x3f), |
702
|
|
|
|
|
|
|
0x80 | ( $c & 0x3f)); |
703
|
|
|
|
|
|
|
} else { |
704
|
0
|
|
|
|
|
|
return _utf8_chr(0xfffd); |
705
|
|
|
|
|
|
|
} |
706
|
|
|
|
|
|
|
} |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
#### |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
sub htmlize { |
711
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
712
|
|
|
|
|
|
|
|
713
|
0
|
|
|
|
|
|
my ($s)=@_; |
714
|
0
|
0
|
|
|
|
|
return ('') if (! defined($s)); |
715
|
0
|
|
|
|
|
|
$s =~ s/\&/\&/gs; |
716
|
0
|
|
|
|
|
|
$s =~ s/>/\>/gs; |
717
|
0
|
|
|
|
|
|
$s =~ s/\</gs; |
718
|
0
|
|
|
|
|
|
$s =~ s/"/\"/gs; |
719
|
0
|
|
|
|
|
|
$s; |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
#### |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
sub url_encode { |
725
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
726
|
0
|
|
|
|
|
|
my ($s)=@_; |
727
|
0
|
0
|
|
|
|
|
return '' if (! defined ($s)); |
728
|
0
|
|
|
|
|
|
$s= pack("C*", unpack("C*", $s)); |
729
|
0
|
|
|
|
|
|
$s=~s/([^-_.a-zA-Z0-9])/sprintf("%%%02x",ord($1))/eg; |
|
0
|
|
|
|
|
|
|
730
|
0
|
|
|
|
|
|
$s; |
731
|
|
|
|
|
|
|
} |
732
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
#### |
734
|
|
|
|
|
|
|
|
735
|
0
|
|
|
0
|
0
|
|
sub param_mime { require Nes::Minimal::Multipart; &_internal_param_mime(@_); } |
|
0
|
|
|
|
|
|
|
736
|
0
|
|
|
0
|
0
|
|
sub param_filename { require Nes::Minimal::Multipart; &_internal_param_filename(@_); } |
|
0
|
|
|
|
|
|
|
737
|
0
|
|
|
0
|
0
|
|
sub date_rfc1123 { require Nes::Minimal::Misc; &_internal_date_rfc1123(@_); } |
|
0
|
|
|
|
|
|
|
738
|
0
|
|
|
0
|
0
|
|
sub dehtmlize { require Nes::Minimal::Misc; &_internal_dehtmlize(@_); } |
|
0
|
|
|
|
|
|
|
739
|
0
|
|
|
0
|
0
|
|
sub url_decode { require Nes::Minimal::Misc; &_internal_url_decode(@_); } |
|
0
|
|
|
|
|
|
|
740
|
0
|
|
|
0
|
0
|
|
sub calling_parms_table { require Nes::Minimal::Misc; &_internal_calling_parms_table(@_); } |
|
0
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
#### |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
1; |
745
|
|
|
|
|
|
|
|