From 73dcaed6aff4a245de910540b7c46a0809fa400f Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Tue, 25 Jan 2022 11:13:08 +0100 Subject: [PATCH] Allow hyphen in file names --- paste.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 2.43.0