gitlab-org--gitlab-foss/config/initializers/workhorse_multipart.rb

26 lines
761 B
Ruby
Raw Normal View History

2016-08-18 10:31:44 -04:00
Rails.application.configure do |config|
config.middleware.use(Gitlab::Middleware::Multipart)
end
2016-12-27 12:12:37 -05:00
# The Gitlab::Middleware::Multipart middleware inserts instances of our
# own ::UploadedFile class in the Rack env of requests. These instances
# will be blocked by the 'strong parameters' feature of ActionController
# unless we somehow whitelist them. At the moment it seems the only way
# to do that is by monkey-patching.
#
module Gitlab
module StrongParameterScalars
2017-02-21 18:32:18 -05:00
GITLAB_PERMITTED_SCALAR_TYPES = [::UploadedFile].freeze
def permitted_scalar?(value)
super || GITLAB_PERMITTED_SCALAR_TYPES.any? { |type| value.is_a?(type) }
end
end
end
module ActionController
class Parameters
prepend Gitlab::StrongParameterScalars
end
end