Skip to content

Commit b10c828

Browse files
committedJul 4, 2012
Merge pull request #90 from knoopx/master
Security Fix
2 parents 0726847 + aeadbed commit b10c828

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed
 

‎lib/mini_magick.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'subexec'
33
require 'stringio'
44
require 'pathname'
5+
require 'shellwords'
56

67
module MiniMagick
78
class << self
@@ -487,7 +488,7 @@ def add_command(command, *options)
487488
end
488489

489490
def escape_string(value)
490-
'"' + value + '"'
491+
Shellwords.escape(value.to_s)
491492
end
492493

493494
def add_creation_operator(command, *options)

‎test/command_builder_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ class CommandBuilderTest < Test::Unit::TestCase
66
def test_basic
77
c = CommandBuilder.new("test")
88
c.resize "30x40"
9-
assert_equal "-resize \"30x40\"", c.args.join(" ")
9+
assert_equal '-resize 30x40', c.args.join(" ")
1010
end
1111

1212
def test_complicated
1313
c = CommandBuilder.new("test")
1414
c.resize "30x40"
1515
c.alpha "1 3 4"
1616
c.resize "mome fingo"
17-
assert_equal "-resize \"30x40\" -alpha \"1 3 4\" -resize \"mome fingo\"", c.args.join(" ")
17+
assert_equal '-resize 30x40 -alpha 1\ 3\ 4 -resize mome\ fingo', c.args.join(" ")
1818
end
1919

2020
def test_plus_modifier_and_multiple_options
2121
c = CommandBuilder.new("test")
2222
c.distort.+ 'srt', '0.6 20'
23-
assert_equal "+distort \"srt\" \"0.6 20\"", c.args.join(" ")
23+
assert_equal '+distort srt 0.6\ 20', c.args.join(" ")
2424
end
2525

2626
def test_valid_command

0 commit comments

Comments
 (0)