From 80ef5e6ba263421c6021307e9fc197a4e7011e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Palomares=20Pizarro?= Date: Mon, 21 Nov 2022 13:02:00 +0100 Subject: [PATCH] append .txt to the filename if the filename is "-" --- http/sakisafe.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/http/sakisafe.pl b/http/sakisafe.pl index 7062539..5804020 100755 --- a/http/sakisafe.pl +++ b/http/sakisafe.pl @@ -24,14 +24,15 @@ sub handle_file { # Generate random string for the directory my @chars = ( '0' .. '9', 'a' .. 'Z' ); $dirname .= $chars[ rand @chars ] for 1 .. 5; - + my $filename = $filedata->filename; mkdir( "f/" . $dirname ); - $filedata->move_to( "f/" . $dirname . "/" . $filedata->filename ); + $filename .= ".txt" if $filename eq "-"; + $filedata->move_to( "f/" . $dirname . "/" . $filename ); my $host = $c->req->url->to_abs->host; $c->res->headers->header( 'Location' => "http://$host/$dirname/" . $filedata->filename ); $c->render( - text => "Uploaded to http://$host/f/$dirname/" . $filedata->filename, + text => "http://$host/f/$dirname/" . $filename, status => 201, ); $dirname = "";