1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Don't need to validate transformations actually

Since they're only ever generated in signed form. Users never have direct access to dictate transformations.
This commit is contained in:
David Heinemeier Hansson 2017-07-22 09:38:16 -05:00
parent 5fcaa197a7
commit 470ba69403

View file

@ -4,11 +4,6 @@ require "active_support/core_ext/object/inclusion"
class ActiveStorage::Variation
class_attribute :verifier
ALLOWED_TRANSFORMATIONS = %i(
resize rotate format flip fill monochrome orient quality roll scale sharpen shave shear size thumbnail
transparent transpose transverse trim background bordercolor compress crop
)
attr_reader :transformations
class << self
@ -27,8 +22,6 @@ class ActiveStorage::Variation
def transform(image)
transformations.each do |(method, argument)|
next unless eligible_transformation?(method)
if eligible_argument?(argument)
image.public_send(method, argument)
else
@ -42,11 +35,6 @@ class ActiveStorage::Variation
end
private
def eligible_transformation?(method)
method.to_sym.in?(ALLOWED_TRANSFORMATIONS)
end
# FIXME: Consider whitelisting allowed arguments as well?
def eligible_argument?(argument)
argument.present? && argument != true
end