mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 21:53:51 +08:00
FIX: Raise a 4xx error instead of a 5xx if draft data is invalid
This commit is contained in:
parent
3de901e38d
commit
0ae504aece
|
@ -51,7 +51,13 @@ class DraftController < ApplicationController
|
|||
|
||||
json = success_json.merge(draft_sequence: sequence)
|
||||
|
||||
if data = JSON::parse(params[:data])
|
||||
begin
|
||||
data = JSON::parse(params[:data])
|
||||
rescue JSON::ParserError
|
||||
raise Discourse::InvalidParameters.new(:data)
|
||||
end
|
||||
|
||||
if data.present?
|
||||
# this is a bit of a kludge we need to remove (all the parsing) too many special cases here
|
||||
# we need to catch action edit and action editSharedDraft
|
||||
if data["postId"].present? && data["originalText"].present? && data["action"].to_s.start_with?("edit")
|
||||
|
|
Loading…
Reference in New Issue
Block a user