mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: Better and more secure validation of periods for TopicQuery
Co-authored-by: Martin Brennan <mjrbrennan@gmail.com>
This commit is contained in:
@ -57,8 +57,13 @@ class EmbedController < ApplicationController
|
||||
end
|
||||
|
||||
topic_query = TopicQuery.new(current_user, list_options)
|
||||
top_period = params[:top_period]&.to_sym
|
||||
valid_top_period = TopTopic.periods.include?(top_period)
|
||||
top_period = params[:top_period]
|
||||
begin
|
||||
TopTopic.validate_period(top_period)
|
||||
valid_top_period = true
|
||||
rescue Discourse::InvalidParameters
|
||||
valid_top_period = false
|
||||
end
|
||||
|
||||
@list = if valid_top_period
|
||||
topic_query.list_top_for(top_period)
|
||||
|
Reference in New Issue
Block a user