Revision 5d557254
Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
70 | 70 |
sub _store_value { |
71 | 71 |
$main::lxdebug->enter_sub(2); |
72 | 72 |
|
73 |
my $self = shift;
|
|
73 |
my $curr = shift;
|
|
74 | 74 |
my $key = shift; |
75 | 75 |
my $value = shift; |
76 | 76 |
|
77 |
my $curr = $self; |
|
78 |
|
|
79 | 77 |
while ($key =~ /\[\+?\]\.|\./) { |
80 | 78 |
substr($key, 0, $+[0]) = ''; |
81 | 79 |
|
... | ... | |
103 | 101 |
sub _input_to_hash { |
104 | 102 |
$main::lxdebug->enter_sub(2); |
105 | 103 |
|
106 |
my $self = shift;
|
|
107 |
my $input = shift; |
|
104 |
my $params = shift;
|
|
105 |
my $input = shift;
|
|
108 | 106 |
|
109 |
my @pairs = split(/&/, $input); |
|
107 |
my @pairs = split(/&/, $input);
|
|
110 | 108 |
|
111 | 109 |
foreach (@pairs) { |
112 | 110 |
my ($key, $value) = split(/=/, $_, 2); |
113 |
$self->_store_value($self->unescape($key), $self->unescape($value));
|
|
111 |
_store_value($params, unescape(undef, $key), unescape(undef, $value));
|
|
114 | 112 |
} |
115 | 113 |
|
116 | 114 |
$main::lxdebug->leave_sub(2); |
... | ... | |
119 | 117 |
sub _request_to_hash { |
120 | 118 |
$main::lxdebug->enter_sub(2); |
121 | 119 |
|
122 |
my $self = shift;
|
|
123 |
my $input = shift; |
|
120 |
my $params = shift;
|
|
121 |
my $input = shift;
|
|
124 | 122 |
|
125 | 123 |
if (!$ENV{'CONTENT_TYPE'} |
126 | 124 |
|| ($ENV{'CONTENT_TYPE'} !~ /multipart\/form-data\s*;\s*boundary\s*=\s*(.+)$/)) { |
127 | 125 |
|
128 |
$self->_input_to_hash($input);
|
|
126 |
_input_to_hash($params, $input);
|
|
129 | 127 |
|
130 | 128 |
$main::lxdebug->leave_sub(2); |
131 | 129 |
return; |
... | ... | |
173 | 171 |
substr $line, $-[0], $+[0] - $-[0], ""; |
174 | 172 |
} |
175 | 173 |
|
176 |
$previous = $self->_store_value($name, '');
|
|
177 |
$self->{FILENAME} = $filename if ($filename);
|
|
174 |
$previous = _store_value($params, $name, '');
|
|
175 |
$params->{FILENAME} = $filename if ($filename);
|
|
178 | 176 |
|
179 | 177 |
next; |
180 | 178 |
} |
... | ... | |
196 | 194 |
$main::lxdebug->leave_sub(2); |
197 | 195 |
} |
198 | 196 |
|
197 |
sub _recode_recursively { |
|
198 |
my ($iconv, $param) = @_; |
|
199 |
|
|
200 |
if (ref $param eq 'HASH') { |
|
201 |
foreach my $key (keys %{ $param }) { |
|
202 |
if (!ref $param->{$key}) { |
|
203 |
$param->{$key} = $iconv->convert($param->{$key}); |
|
204 |
} else { |
|
205 |
_recode_recursively($iconv, $param->{$key}); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
} elsif (ref $param eq 'ARRAY') { |
|
210 |
foreach my $idx (0 .. scalar(@{ $param }) - 1) { |
|
211 |
if (!ref $param->[$idx]) { |
|
212 |
$param->[$idx] = $iconv->convert($param->[$idx]); |
|
213 |
} else { |
|
214 |
_recode_recursively($iconv, $param->[$idx]); |
|
215 |
} |
|
216 |
} |
|
217 |
} |
|
218 |
} |
|
219 |
|
|
199 | 220 |
sub new { |
200 | 221 |
$main::lxdebug->enter_sub(); |
201 | 222 |
|
... | ... | |
220 | 241 |
|
221 | 242 |
bless $self, $type; |
222 | 243 |
|
223 |
$self->_request_to_hash($_); |
|
244 |
my $parameters = { }; |
|
245 |
_request_to_hash($parameters, $_); |
|
246 |
|
|
247 |
my $db_charset = $main::dbcharset; |
|
248 |
$db_charset ||= Common::DEFAULT_CHARSET; |
|
249 |
|
|
250 |
if ($parameters->{INPUT_ENCODING} && (lc $parameters->{INPUT_ENCODING} ne $db_charset)) { |
|
251 |
require Text::Iconv; |
|
252 |
my $iconv = Text::Iconv->new($parameters->{INPUT_ENCODING}, $db_charset); |
|
253 |
|
|
254 |
_recode_recursively($iconv, $parameters); |
|
255 |
|
|
256 |
delete $parameters{INPUT_ENCODING}; |
|
257 |
} |
|
258 |
|
|
259 |
map { $self->{$_} = $parameters->{$_}; } keys %{ $parameters }; |
|
224 | 260 |
|
225 | 261 |
$self->{action} = lc $self->{action}; |
226 | 262 |
$self->{action} =~ s/( |-|,|\#)/_/g; |
Auch abrufbar als: Unified diff
Die JavaScript-Funktion "encodeURIComponent()" benutzt immer UTF-8 als Zeichensatz, egal, was die HTTP-Header oder das <form>-Element sagen. Also muss der Input bei Erhalt in den Zeichensatz der Installation konvertiert werden.