Escape user input before building regexps

This commit is contained in:
rulingcom committed 2026-10-24 13:17:15 +08:00
1 parent bcb3ddad7e
commit c74af93eee
1 file changed
+1 -1
+1 -1
View File
@@ -39,7 +39,7 @@ class CurationPostsController < ApplicationController
if !params[:category].blank?
module_id = ModuleApp.where(:key=>"curation").first.id
category = Regexp.new(".*"+params[:category]+".*")
category = Regexp.new(".*"+Regexp.escape(params[:category].to_s)+".*")
category_id = Category.where(:title => category, :module_app_id => module_id).first.id
bulletins = bulletins.where(:category_id => category_id)
else