diff --git a/lib/grim/image_magick_processor.rb b/lib/grim/image_magick_processor.rb index bb16174..0acd01d 100644 --- a/lib/grim/image_magick_processor.rb +++ b/lib/grim/image_magick_processor.rb @@ -59,7 +59,7 @@ def prepare_command(pdf, index, path, options) command << "-interlace none" command << "-density #{density}" command << "#{Shellwords.shellescape(pdf.path)}[#{index}]" - command << path + command << Shellwords.shellescape(path) command end diff --git a/spec/lib/grim/image_magick_processor_spec.rb b/spec/lib/grim/image_magick_processor_spec.rb index db10062..dc6246c 100644 --- a/spec/lib/grim/image_magick_processor_spec.rb +++ b/spec/lib/grim/image_magick_processor_spec.rb @@ -50,6 +50,20 @@ end end + describe "#save to path includes shell meta character" do + before(:all) do + @path = tmp_path("to_png_spec(1).png") + @pdf = Grim::Pdf.new(fixture_path("smoker.pdf")) + + @processor = Grim::ImageMagickProcessor.new + end + + it "should success" do + @processor.save(@pdf, 0, @path, {}) + expect(File.exist?(@path)).to be(true) + end + end + describe "#save with width option" do before(:each) do @path = tmp_path("to_png_spec.png")