mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
SECURITY: Limit the length of drafts (#19989)
Co-authored-by: Loïc Guitaut <loic@discourse.org>
This commit is contained in:
@ -24,6 +24,16 @@ class DraftsController < ApplicationController
|
||||
def create
|
||||
raise Discourse::NotFound.new if params[:draft_key].blank?
|
||||
|
||||
if params[:data].size > SiteSetting.max_draft_length
|
||||
raise Discourse::InvalidParameters.new(:data)
|
||||
end
|
||||
|
||||
begin
|
||||
data = JSON.parse(params[:data])
|
||||
rescue JSON::ParserError
|
||||
raise Discourse::InvalidParameters.new(:data)
|
||||
end
|
||||
|
||||
sequence =
|
||||
begin
|
||||
Draft.set(
|
||||
@ -59,12 +69,6 @@ class DraftsController < ApplicationController
|
||||
|
||||
json = success_json.merge(draft_sequence: sequence)
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user