]> www.fi.muni.cz Git - paste.git/blobdiff - paste.pl
Allow hyphen in file names
[paste.git] / paste.pl
index fbbb0cc0197859ba3aff27f1e49a1feaa12d9fb2..7f3f5ff94ef3d557f301902fe36f7dbca9c1fa37 100755 (executable)
--- 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>.<ext>'
-       => [ 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);
@@ -65,6 +65,7 @@ get '/<filename>.<ext>'
        $c->render;
 } => 'default';
 
+app->mode(app->config->{mode});
 app->start;
 
 __DATA__
@@ -172,7 +173,7 @@ __DATA__
     <%= content %>
     <div class="footer">
       Created by <b>Yenya's Paste Bin</b>,
-        <a href="https://www.fi.muni.cz/~kas/git/paste/">www.fi.muni.cz/~kas/git/paste</a>
+        <a href="https://www.fi.muni.cz/~kas/git/paste.git/">www.fi.muni.cz/~kas/git/paste</a>
     </div>
   </div></body>
 </html>