Skip to content

Commit 74ce502

Browse files
committed
explicitly parse JSON request bodies
1 parent 0064826 commit 74ce502

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

lib/chatops/controller.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ def execute_chatop
5050
protected
5151

5252
def setup_params
53+
json_body.each do |key, value|
54+
next if params.has_key? key
55+
params[key] = value
56+
end
57+
5358
permitted_params = %i[
5459
action
5560
chatop
@@ -76,6 +81,14 @@ def setup_params
7681
self.params = params.permit(*permitted_params)
7782
end
7883

84+
def json_body
85+
hash = {}
86+
if request.content_type =~ %r/\Aapplication\/json\Z/i
87+
hash = GitHub::JSON.parse(request.raw_post) || {}
88+
end
89+
hash.with_indifferent_access
90+
end
91+
7992
def jsonrpc_params
8093
params["params"] || {}
8194
end

0 commit comments

Comments
 (0)