Fix filenames with double-quotes

pull/8/head
Nemo 3 years ago
parent 4a358d0cb0
commit ff225b12c6
  1. 9
      spec/util_spec.cr
  2. 2
      src/util.cr

@ -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

@ -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

Loading…
Cancel
Save