Commit ab70e2ab authored by Dietmar Maurer's avatar Dietmar Maurer

do not call uri_unescape on whole url - only on path

Because parameters are decoded with extract_params().
parent f7a7efb4
...@@ -681,12 +681,10 @@ sub extract_params { ...@@ -681,12 +681,10 @@ sub extract_params {
} }
sub handle_api2_request { sub handle_api2_request {
my ($self, $reqstate, $auth, $upload_state) = @_; my ($self, $reqstate, $auth, $method, $path, $upload_state) = @_;
eval { eval {
my $r = $reqstate->{request}; my $r = $reqstate->{request};
my $method = $r->method();
my $path = $r->uri->path();
my ($rel_uri, $format) = split_abs_uri($path); my ($rel_uri, $format) = split_abs_uri($path);
...@@ -926,19 +924,17 @@ sub handle_spice_proxy_request { ...@@ -926,19 +924,17 @@ sub handle_spice_proxy_request {
} }
sub handle_request { sub handle_request {
my ($self, $reqstate, $auth) = @_; my ($self, $reqstate, $auth, $method, $path) = @_;
eval { eval {
my $r = $reqstate->{request}; my $r = $reqstate->{request};
my $method = $r->method();
my $path = $r->uri->path();
# disable timeout on handle (we already have all data we need) # disable timeout on handle (we already have all data we need)
# we re-enable timeout in response() # we re-enable timeout in response()
$reqstate->{hdl}->timeout(0); $reqstate->{hdl}->timeout(0);
if ($path =~ m!$baseuri!) { if ($path =~ m!$baseuri!) {
$self->handle_api2_request($reqstate, $auth); $self->handle_api2_request($reqstate, $auth, $method, $path);
return; return;
} }
...@@ -983,7 +979,7 @@ sub handle_request { ...@@ -983,7 +979,7 @@ sub handle_request {
} }
sub file_upload_multipart { sub file_upload_multipart {
my ($self, $reqstate, $auth, $rstate) = @_; my ($self, $reqstate, $auth, $method, $path, $rstate) = @_;
eval { eval {
my $boundary = $rstate->{boundary}; my $boundary = $rstate->{boundary};
...@@ -1085,7 +1081,7 @@ sub file_upload_multipart { ...@@ -1085,7 +1081,7 @@ sub file_upload_multipart {
syslog('info', "multipart upload complete " . syslog('info', "multipart upload complete " .
"(size: %d time: %ds rate: %.2fMiB/s md5sum: $rstate->{md5sum})", "(size: %d time: %ds rate: %.2fMiB/s md5sum: $rstate->{md5sum})",
$rstate->{bytes}, $elapsed, $rate); $rstate->{bytes}, $elapsed, $rate);
$self->handle_api2_request($reqstate, $auth, $rstate); $self->handle_api2_request($reqstate, $auth, $method, $path, $rstate);
} }
} }
}; };
...@@ -1155,7 +1151,7 @@ sub unshift_read_header { ...@@ -1155,7 +1151,7 @@ sub unshift_read_header {
my $r = $reqstate->{request}; my $r = $reqstate->{request};
if ($line eq '') { if ($line eq '') {
my $path = $r->uri->path(); my $path = uri_unescape($r->uri->path());
my $method = $r->method(); my $method = $r->method();
$r->push_header($state->{key}, $state->{val}) $r->push_header($state->{key}, $state->{val})
...@@ -1293,7 +1289,7 @@ sub unshift_read_header { ...@@ -1293,7 +1289,7 @@ sub unshift_read_header {
outfh => $outfh, outfh => $outfh,
}; };
$reqstate->{tmpfilename} = $tmpfilename; $reqstate->{tmpfilename} = $tmpfilename;
$reqstate->{hdl}->on_read(sub { $self->file_upload_multipart($reqstate, $auth, $state); }); $reqstate->{hdl}->on_read(sub { $self->file_upload_multipart($reqstate, $auth, $method, $path, $state); });
return; return;
} }
...@@ -1306,13 +1302,13 @@ sub unshift_read_header { ...@@ -1306,13 +1302,13 @@ sub unshift_read_header {
$reqstate->{hdl}->unshift_read(chunk => $len, sub { $reqstate->{hdl}->unshift_read(chunk => $len, sub {
my ($hdl, $data) = @_; my ($hdl, $data) = @_;
$r->content($data); $r->content($data);
$self->handle_request($reqstate, $auth); $self->handle_request($reqstate, $auth, $method, $path);
}); });
} else { } else {
$self->error($reqstate, 506, "upload 'Content-Type '$ctype' not implemented"); $self->error($reqstate, 506, "upload 'Content-Type '$ctype' not implemented");
} }
} else { } else {
$self->handle_request($reqstate, $auth); $self->handle_request($reqstate, $auth, $method, $path);
} }
} elsif ($line =~ /^([^:\s]+)\s*:\s*(.*)/) { } elsif ($line =~ /^([^:\s]+)\s*:\s*(.*)/) {
$r->push_header($state->{key}, $state->{val}) if $state->{key}; $r->push_header($state->{key}, $state->{val}) if $state->{key};
...@@ -1358,7 +1354,7 @@ sub push_request_header { ...@@ -1358,7 +1354,7 @@ sub push_request_header {
$reqstate->{proto}->{maj} = $maj; $reqstate->{proto}->{maj} = $maj;
$reqstate->{proto}->{min} = $min; $reqstate->{proto}->{min} = $min;
$reqstate->{proto}->{ver} = $maj*1000+$min; $reqstate->{proto}->{ver} = $maj*1000+$min;
$reqstate->{request} = HTTP::Request->new($method, uri_unescape($url)); $reqstate->{request} = HTTP::Request->new($method, $url);
$reqstate->{starttime} = [gettimeofday], $reqstate->{starttime} = [gettimeofday],
$self->unshift_read_header($reqstate); $self->unshift_read_header($reqstate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment