From: Jan "Yenya" Kasprzak Date: Tue, 25 Jan 2022 10:13:08 +0000 (+0100) Subject: Allow hyphen in file names X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=paste.git;a=commitdiff_plain;h=73dcaed6aff4a245de910540b7c46a0809fa400f Allow hyphen in file names --- diff --git a/paste.pl b/paste.pl index a750dfa..7f3f5ff 100755 --- a/paste.pl +++ b/paste.pl @@ -37,7 +37,7 @@ post '/' => sub ($c) { $file_content = $upload->slurp; } - if ($filename !~ /\A\w[\w\.]*\.\w+\z/) { + if ($filename !~ /\A\w[\w-\.]*\.\w+\z/) { # print STDERR "FILENAME2 = " . $upload->filename . "\n"; return $c->render(template => 'forbidden', status => 403); } @@ -47,7 +47,7 @@ post '/' => sub ($c) { }; get '/.' - => [ filename => qr/\w[\w\.]*/, ext => qr/\w+/ ] + => [ filename => qr/\w[\w-\.]*/, ext => qr/\w+/ ] => sub ($c) { my $fullname = $c->param('filename').'.'.$c->param('ext'); my $file = $datadir->child($fullname);