X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Fperl%2FUCW%2FCGI.pm;h=de39d226aad349f54810f9092338f0ac16b3ec27;hb=68de14ab2618ebf4afa9630299cef5eafe13d1be;hp=7cb346391d6a1f89dd6ee78118c197df6624d3d0;hpb=39b28bffc195348b93294b5fa0a8b9e87ea7317a;p=libucw.git diff --git a/ucw/perl/UCW/CGI.pm b/ucw/perl/UCW/CGI.pm index 7cb34639..de39d226 100644 --- a/ucw/perl/UCW/CGI.pm +++ b/ucw/perl/UCW/CGI.pm @@ -31,6 +31,7 @@ sub http_error($;@) { sub url_escape($) { my $x = shift @_; + defined $x or return; utf8::encode($x) if $utf8_mode; $x =~ s/([^-\$_.!*'(),0-9A-Za-z\x80-\xff])/"%".unpack('H2',$1)/ge; utf8::decode($x) if $utf8_mode; @@ -39,6 +40,7 @@ sub url_escape($) { sub url_deescape($) { my $x = shift @_; + defined $x or return; utf8::encode($x) if $utf8_mode; $x =~ s/%(..)/pack("H2",$1)/ge; utf8::decode($x) if $utf8_mode; @@ -47,19 +49,24 @@ sub url_deescape($) { sub url_param_escape($) { my $x = shift @_; - $x = url_escape($x); + defined $x or return; + utf8::encode($x) if $utf8_mode; + $x =~ s/([^-\$_.!*'(),0-9A-Za-z])/"%".unpack('H2',$1)/ge; $x =~ s/%20/+/g; + utf8::decode($x) if $utf8_mode; return $x; } sub url_param_deescape($) { my $x = shift @_; + defined $x or return; $x =~ s/\+/ /g; return url_deescape($x); } sub html_escape($) { my $x = shift @_; + defined $x or return; $x =~ s/&/&/g; $x =~ s//>/g; @@ -364,6 +371,10 @@ sub parse_multipart_form_data() { print STDERR "FILE UPLOAD to $fn\n" if $debug; ${$a->{"file"}} = $fn; ${$a->{"fh"}} = $fh if defined $a->{"fh"}; + if (defined $a->{"filename"}){ + my ($filename) = ($cdisp =~ /;filename=([^;]+)/); + (${$a->{"filename"}}) = rfc822_deescape($filename) if defined $filename; + } my $total_size = 0; while (my $i = refill_mp_data(4096)) { print $fh substr($mp_buffer, $mp_buffer_i, $i);