]> www.fi.muni.cz Git - paste.git/blobdiff - paste.pl
Allow hyphen in file names
[paste.git] / paste.pl
index 6c25fde748cb255b810df5780024e546215ab4e6..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__
@@ -90,8 +91,8 @@ __DATA__
 
 %= content_for header => begin
     <base href="<%= config->{base} %>/">
-    <link rel="stylesheet" href="highlight/qtcreator-dark.min.css">
-    <script src="highlight/highlight.min.js"></script>
+    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/qtcreator-dark.min.css">
+    <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/highlight.min.js"></script>
     <script>hljs.highlightAll();</script>
 % end
 
@@ -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>