dragonfly 1.1.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of dragonfly might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.md +9 -0
- data/lib/dragonfly/content.rb +4 -4
- data/lib/dragonfly/shell.rb +19 -13
- data/lib/dragonfly/version.rb +1 -1
- data/samples/white pixel.png b/data/samples/mevs' white → pixel.png +0 -0
- data/spec/dragonfly/content_spec.rb +3 -3
- data/spec/dragonfly/image_magick/processors/convert_spec.rb +3 -3
- data/spec/dragonfly/shell_spec.rb +12 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a47133559b55bb240e3e977a7a21bf6c20b3bb0
|
4
|
+
data.tar.gz: 2e8427ea7731176f305fa8c9db9021b0fcb993f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b913360c4b6b7d3aa3eec21616ecf5f02b3e39b674a30bf31bbe696380b0326e2b2b918b91ac3f8858b62af5ac3a5966dc843de941104e219e28e0afcc2e0d0
|
7
|
+
data.tar.gz: a1e0950d8088f9237df79290bdef52b01e6eae07f42792974eb23e2386134d9f3759c9d05ea8f077eaf5f99f8abe12eb56686a164b867347c6684665f75ba469
|
data/History.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
1.2.0 (2018-11-13)
|
2
|
+
===================
|
3
|
+
Fixes
|
4
|
+
-----
|
5
|
+
- Replaced `quote` with `escape` for escaping shell commands - works with paths with apostrophes
|
6
|
+
Changes
|
7
|
+
-----
|
8
|
+
- Replaced Open3.popen3 with now recommended Open3.capture3 (tomasc)
|
9
|
+
|
1
10
|
1.1.5 (2018-03-23)
|
2
11
|
===================
|
3
12
|
Fixes
|
data/lib/dragonfly/content.rb
CHANGED
@@ -137,7 +137,7 @@ module Dragonfly
|
|
137
137
|
# # ===> "beach.jpg: image/jpeg"
|
138
138
|
def shell_eval(opts={})
|
139
139
|
should_escape = opts[:escape] != false
|
140
|
-
command = yield(should_escape ? shell.
|
140
|
+
command = yield(should_escape ? shell.escape(path) : path)
|
141
141
|
run command, :escape => should_escape
|
142
142
|
end
|
143
143
|
|
@@ -152,7 +152,7 @@ module Dragonfly
|
|
152
152
|
ext = opts[:ext] || self.ext
|
153
153
|
should_escape = opts[:escape] != false
|
154
154
|
tempfile = Utils.new_tempfile(ext)
|
155
|
-
new_path = should_escape ? shell.
|
155
|
+
new_path = should_escape ? shell.escape(tempfile.path) : tempfile.path
|
156
156
|
command = yield(new_path)
|
157
157
|
run(command, :escape => should_escape)
|
158
158
|
update(tempfile)
|
@@ -169,8 +169,8 @@ module Dragonfly
|
|
169
169
|
ext = opts[:ext] || self.ext
|
170
170
|
should_escape = opts[:escape] != false
|
171
171
|
tempfile = Utils.new_tempfile(ext)
|
172
|
-
old_path = should_escape ? shell.
|
173
|
-
new_path = should_escape ? shell.
|
172
|
+
old_path = should_escape ? shell.escape(path) : path
|
173
|
+
new_path = should_escape ? shell.escape(tempfile.path) : tempfile.path
|
174
174
|
command = yield(old_path, new_path)
|
175
175
|
run(command, :escape => should_escape)
|
176
176
|
update(tempfile)
|
data/lib/dragonfly/shell.rb
CHANGED
@@ -15,14 +15,11 @@ module Dragonfly
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def escape_args(args)
|
18
|
-
args.shellsplit.map
|
19
|
-
quote arg.gsub(/\\?'/, %q('\\\\''))
|
20
|
-
end.join(' ')
|
18
|
+
args.shellsplit.map{|arg| escape(arg) }.join(' ')
|
21
19
|
end
|
22
20
|
|
23
|
-
def
|
24
|
-
|
25
|
-
q + string + q
|
21
|
+
def escape(string)
|
22
|
+
Shellwords.escape(string)
|
26
23
|
end
|
27
24
|
|
28
25
|
private
|
@@ -36,22 +33,31 @@ module Dragonfly
|
|
36
33
|
def run_command(command)
|
37
34
|
result = `#{command}`
|
38
35
|
status = $?
|
39
|
-
|
36
|
+
raise_command_failed!(command, status.exitstatus) unless status.success?
|
40
37
|
result
|
38
|
+
rescue Errno::ENOENT => e
|
39
|
+
raise_command_failed!(command, nil, e.message)
|
41
40
|
end
|
42
41
|
|
43
42
|
else
|
44
43
|
|
45
44
|
def run_command(command)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
45
|
+
stdout_str, stderr_str, status = Open3.capture3(command)
|
46
|
+
raise_command_failed!(command, status.exitstatus, stderr_str) unless status.success?
|
47
|
+
stdout_str
|
48
|
+
rescue Errno::ENOENT => e
|
49
|
+
raise_command_failed!(command, nil, e.message)
|
52
50
|
end
|
53
51
|
|
54
52
|
end
|
55
53
|
|
54
|
+
def raise_command_failed!(command, status=nil, error=nil)
|
55
|
+
raise CommandFailed, [
|
56
|
+
"Command failed: #{command}",
|
57
|
+
("exit status: #{status}" if status),
|
58
|
+
("error: #{error}" if error),
|
59
|
+
].join(', ')
|
60
|
+
end
|
61
|
+
|
56
62
|
end
|
57
63
|
end
|
data/lib/dragonfly/version.rb
CHANGED
File without changes
|
@@ -232,7 +232,7 @@ describe Dragonfly::Content do
|
|
232
232
|
path = p
|
233
233
|
"cat #{path}"
|
234
234
|
end.should == "big\nstuff"
|
235
|
-
path.should == app.shell.
|
235
|
+
path.should == app.shell.escape(content.path)
|
236
236
|
end
|
237
237
|
|
238
238
|
it "allows evaluating without escaping" do
|
@@ -253,8 +253,8 @@ describe Dragonfly::Content do
|
|
253
253
|
new_path = n
|
254
254
|
"cp #{o} #{n}"
|
255
255
|
end.should == content
|
256
|
-
old_path.should == app.shell.
|
257
|
-
new_path.should == app.shell.
|
256
|
+
old_path.should == app.shell.escape(original_path)
|
257
|
+
new_path.should == app.shell.escape(content.path)
|
258
258
|
content.data.should == "big\nstuff"
|
259
259
|
end
|
260
260
|
|
@@ -29,8 +29,8 @@ describe Dragonfly::ImageMagick::Processors::Convert do
|
|
29
29
|
image.should have_width(280)
|
30
30
|
end
|
31
31
|
|
32
|
-
it "should work for files with spaces in the name" do
|
33
|
-
image = Dragonfly::Content.new(app, SAMPLES_DIR.join('white pixel.png
|
32
|
+
it "should work for files with spaces/apostrophes in the name" do
|
33
|
+
image = Dragonfly::Content.new(app, SAMPLES_DIR.join("mevs' white pixel.png"))
|
34
34
|
processor.call(image, "-resize 2x2!")
|
35
35
|
image.should have_width(2)
|
36
36
|
end
|
@@ -65,7 +65,7 @@ describe Dragonfly::ImageMagick::Processors::Convert do
|
|
65
65
|
it "allows converting using specific delegates" do
|
66
66
|
expect {
|
67
67
|
processor.call(image, '', 'format' => 'jpg', 'delegate' => 'png')
|
68
|
-
}.to call_command(app.shell, %r{
|
68
|
+
}.to call_command(app.shell, %r{convert png:/[^']+?/beach\.png /[^']+?\.jpg})
|
69
69
|
end
|
70
70
|
|
71
71
|
it "maintains the mime_type meta if it exists already" do
|
@@ -22,19 +22,21 @@ describe Dragonfly::Shell do
|
|
22
22
|
|
23
23
|
unless Dragonfly.running_on_windows?
|
24
24
|
|
25
|
+
# NOTE: every \\ translates to a single \ on the command line
|
25
26
|
describe "escaping args" do
|
26
27
|
{
|
27
|
-
%q(hello) => %q(
|
28
|
-
%q(
|
29
|
-
%q('
|
30
|
-
%q(he
|
31
|
-
%q(
|
32
|
-
%q(
|
33
|
-
%q(hel$(lo)) => %q(
|
34
|
-
%q(hel
|
35
|
-
%q('hel
|
28
|
+
%q(hello there) => %q(hello there),
|
29
|
+
%q('hello' 'there') => %q(hello there),
|
30
|
+
%q(he\\'llo there) => %q(he\\'llo there),
|
31
|
+
%q(he\\ llo there) => %q(he\\ llo there),
|
32
|
+
%q("he'llo" there) => %q(he\\'llo there),
|
33
|
+
%q('he'\\''llo' there) => %q(he\\'llo there),
|
34
|
+
%q(hel$(lo) there) => %q(hel\\$\\(lo\\) there),
|
35
|
+
%q(hel\\$(lo) > there) => %q(hel\\$\\(lo\\) \\> there),
|
36
|
+
%q('hel$(lo) > there') => %q(hel\\$\\(lo\\)\\ \\>\\ there),
|
37
|
+
%q(hello -there) => %q(hello -there),
|
36
38
|
}.each do |args, escaped_args|
|
37
|
-
it "should escape #{args
|
39
|
+
it "should escape #{args} -> #{escaped_args}" do
|
38
40
|
shell.escape_args(args).should == escaped_args
|
39
41
|
end
|
40
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragonfly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -178,10 +178,10 @@ files:
|
|
178
178
|
- samples/beach.png
|
179
179
|
- samples/egg.png
|
180
180
|
- samples/gif.gif
|
181
|
+
- samples/mevs' white pixel.png
|
181
182
|
- samples/round.gif
|
182
183
|
- samples/sample.docx
|
183
184
|
- samples/taj.jpg
|
184
|
-
- samples/white pixel.png
|
185
185
|
- spec/dragonfly/app_spec.rb
|
186
186
|
- spec/dragonfly/configurable_spec.rb
|
187
187
|
- spec/dragonfly/content_spec.rb
|