2016-08-18 10:31:44 -04:00
|
|
|
Rails.application.configure do |config|
|
|
|
|
config.middleware.use(Gitlab::Middleware::Multipart)
|
|
|
|
end
|
2016-12-23 07:42:42 -05:00
|
|
|
|
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.
|
|
|
|
#
|
2016-12-23 07:42:42 -05:00
|
|
|
module Gitlab
|
|
|
|
module StrongParameterScalars
|
2017-02-21 18:32:18 -05:00
|
|
|
GITLAB_PERMITTED_SCALAR_TYPES = [::UploadedFile].freeze
|
2016-12-23 07:42:42 -05:00
|
|
|
|
|
|
|
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
|