mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 16:23:50 +08:00
SECURITY: restrict constantize classes in search controller
This commit is contained in:
parent
1e241dedad
commit
2b81c593f5
|
@ -81,9 +81,10 @@ class SearchController < ApplicationController
|
||||||
context_obj = nil
|
context_obj = nil
|
||||||
if ['user','private_messages'].include? search_context[:type]
|
if ['user','private_messages'].include? search_context[:type]
|
||||||
context_obj = User.find_by(username_lower: search_context[:id].downcase)
|
context_obj = User.find_by(username_lower: search_context[:id].downcase)
|
||||||
else
|
elsif 'category' == search_context[:type]
|
||||||
klass = search_context[:type].classify.constantize
|
context_obj = Category.find_by(id: search_context[:id].to_i)
|
||||||
context_obj = klass.find_by(id: search_context[:id])
|
elsif 'topic' == search_context[:type]
|
||||||
|
context_obj = Topic.find_by(id: search_context[:id].to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
type_filter = nil
|
type_filter = nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user