]> www.fi.muni.cz Git - paste.git/commitdiff
Handle UTF-8 gracefully
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 21 Apr 2022 14:29:10 +0000 (16:29 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 21 Apr 2022 14:29:10 +0000 (16:29 +0200)
paste.pl

index 8103a94b435860acdd76c9239608dfec7999a978..d8b628cc546bc424fe97bd8f26c00659f41e0a07 100755 (executable)
--- a/paste.pl
+++ b/paste.pl
@@ -58,7 +58,9 @@ get '/<filename>.<ext>'
 
        $c->stash(mtime => POSIX::strftime('%Y-%m-%d %H:%M:%S',
                localtime($stat->mtime)));
-       $c->stash(file_content => $file->slurp);
+       my $content = $file->slurp;
+       $content = Encode::decode('utf-8', $content);
+       $c->stash(file_content => $content);
        my $lang = $c->param('ext');
 
        $c->stash(language => "language-$lang");