mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
FIX: Ensure poll extraction is not attempted if post body is absent (#19718)
Since the poll post handler runs very early in the post creation process, it's possible to run the handler on an obiviously invalid post. This change ensures the post's `raw` value is present before proceeding.
This commit is contained in:
@ -306,6 +306,10 @@ class DiscoursePoll::Poll
|
||||
end
|
||||
|
||||
def self.extract(raw, topic_id, user_id = nil)
|
||||
# Poll Post handlers get called very early in the post
|
||||
# creation process. `raw` could be nil here.
|
||||
return [] if raw.blank?
|
||||
|
||||
# TODO: we should fix the callback mess so that the cooked version is available
|
||||
# in the validators instead of cooking twice
|
||||
raw = raw.sub(%r{\[quote.+/quote\]}m, "")
|
||||
|
Reference in New Issue
Block a user