Skip to content

Commit 9ec9c67

Browse files
committed
Reject non json formats
1 parent 1ce6947 commit 9ec9c67

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/controllers/v3/application_controller.rb

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class ApplicationController < ActionController::Base
6868
before_action :check_write_permissions!, if: :enforce_write_scope?
6969
before_action :hashify_params
7070
before_action :null_coalesce_body
71+
before_action :reject_non_json_formats
7172

7273
rescue_from CloudController::Blobstore::BlobstoreError, with: :handle_blobstore_error
7374
rescue_from CloudController::Errors::NotAuthenticated, with: :handle_not_authenticated
@@ -211,6 +212,10 @@ def null_coalesce_body
211212
hashed_params[:body] ||= {}
212213
end
213214

215+
def reject_non_json_formats
216+
unprocessable!('Unsupported format') if hashed_params.include?(:format) && hashed_params[:format] != 'json'
217+
end
218+
214219
def membership
215220
@membership ||= Membership.new(current_user)
216221
end

0 commit comments

Comments
 (0)