Skip to content
Permalink
Browse files Browse the repository at this point in the history
Sanitized crop input, logs with Paperclip log function if anything we…
…ird happens
  • Loading branch information
saneki authored and rsantamaria committed Sep 21, 2015
1 parent eb34cc5 commit b4ecd95
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/paperclip_processors/cropper.rb
Expand Up @@ -16,11 +16,16 @@ def crop_command
target = @attachment.instance

if target.cropping?(@attachment.name)
w = target.send :"#{@attachment.name}_crop_w"
h = target.send :"#{@attachment.name}_crop_h"
x = target.send :"#{@attachment.name}_crop_x"
y = target.send :"#{@attachment.name}_crop_y"
["-crop", "#{w}x#{h}+#{x}+#{y}"]
begin
w = Integer(target.send :"#{@attachment.name}_crop_w")
h = Integer(target.send :"#{@attachment.name}_crop_h")
x = Integer(target.send :"#{@attachment.name}_crop_x")
y = Integer(target.send :"#{@attachment.name}_crop_y")
["-crop", "#{w}x#{h}+#{x}+#{y}"]
rescue
Paperclip.log("[papercrop] #{@attachment.name} crop w/h/x/y were non-integer")
return
end
end
end

Expand Down

0 comments on commit b4ecd95

Please sign in to comment.