Skip to content

Commit

Permalink
Merge branch 'deprecation-warning'
Browse files Browse the repository at this point in the history
  • Loading branch information
markevans committed May 19, 2021
2 parents 2539929 + 624edc8 commit e03f48b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/dragonfly/image_magick/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def call(app, opts = {})
app.add_generator :plain, ImageMagick::Generators::Plain.new
app.add_generator :plasma, ImageMagick::Generators::Plasma.new
app.add_generator :text, ImageMagick::Generators::Text.new
app.add_generator :convert do
raise "The convert generator is deprecated for better security - use Dragonfly::ImageMagick::Commands.generate(content, args, format) instead."
end

# Processors
app.add_processor :encode, Processors::Encode.new
Expand All @@ -65,6 +68,9 @@ def call(app, opts = {})
ParamValidators.validate!(amount, &ParamValidators.is_number)
Commands.convert(content, "-rotate #{amount}")
end
app.add_processor :convert do
raise "The convert processor is deprecated for better security - use Dragonfly::ImageMagick::Commands.convert(content, args, opts) instead."
end

# Extra methods
app.define :identify do |cli_args = nil|
Expand Down
14 changes: 14 additions & 0 deletions spec/dragonfly/image_magick/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,18 @@
image.identify("-format %h").chomp.should == "355"
end
end

describe "deprecated convert commands" do
it "raises a deprecated message if using the convert processor" do
expect {
image.convert!("into something").apply
}.to raise_error(/deprecated/i)
end

it "raises a deprecated message if using the convert generator" do
expect {
image.generate!(:convert, "into something").apply
}.to raise_error(/deprecated/i)
end
end
end

0 comments on commit e03f48b

Please sign in to comment.