Skip to content

Commit

Permalink
Item13897: UTF8 decode uploaded file name.
Browse files Browse the repository at this point in the history
  • Loading branch information
vrurg committed Oct 14, 2016
1 parent 16ebeca commit 6dd4c91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 10 additions & 3 deletions core/lib/Foswiki/Engine/PSGI.pm
Expand Up @@ -16,6 +16,8 @@ use v5.14;
use Assert;
use Plack::Request;
use Unicode::Normalize;
use File::Spec ();
use Encode ();

use Foswiki::Class;
extends qw(Foswiki::Engine);
Expand Down Expand Up @@ -185,11 +187,16 @@ around _prepareUploads => sub {
my @uploads;
my $psgi = $this->psgi;
foreach my $key ( keys %{ $psgi->uploads } ) {
my $upload = $psgi->upload($key);
my $upload = $psgi->upload($key);
my $filename = Encode::decode_utf8( $upload->filename );
my $basename = ( File::Spec->splitpath($filename) )[2];

# SMELL Not only filenames but all data should be passed thru
# decode_utf8.
push @uploads,
{
filename => $upload->filename,
basename => $upload->basename,
filename => $filename,
basename => $basename,
tmpname => $upload->path,
headers => $upload->headers,
contentType => $upload->content_type,
Expand Down
1 change: 0 additions & 1 deletion core/lib/Foswiki/Validation.pm
Expand Up @@ -322,7 +322,6 @@ sub validate {
# When the redirect is validated it should pass, because
# it will now be using the validation code from the
# confirmation screen that brought us here.
Foswiki::load_class('Foswiki::Request::Cache');
$app->create('Foswiki::Request::Cache')
->load( $cacheUID, $req );
$url = $req->url();
Expand Down

0 comments on commit 6dd4c91

Please sign in to comment.