Fix filenames with double-quotes

This commit is contained in:
Nemo 2020-04-08 00:55:59 +05:30
parent 4a358d0cb0
commit ff225b12c6
2 changed files with 10 additions and 1 deletions

9
spec/util_spec.cr Normal file
View File

@ -0,0 +1,9 @@
require "../src/util"
require "./spec_helper"
describe Muse::Dl::Util do
it "should sanitize filenames properly" do
fn = Muse::Dl::Util.slug_filename("Hello world - \" :A$3, a story; a poem|chapter")
fn.should eq "Hello world - - -A-3, a story- a poem-chapter"
end
end

View File

@ -2,7 +2,7 @@ module Muse::Dl
class Util
# Generates a safe filename
def self.slug_filename(input : String)
input.strip.tr("\u{202E}%$|:;/\t\r\n\\", "-")
input.strip.tr("\u{202E}%$|:;/\"\t\r\n\\", "-")
end
end
end