A platform for community discussion. Free, open, simple.
DEV: Use safer SQL function for string queries when searching groups (#26851)
Daniel Waterworthd937f5b098f7
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rbindex a7ff959682b..b91559d3df2 100644--- a/app/controllers/groups_controller.rb+++ b/app/controllers/groups_controller.rb@@ -638,7 +638,10 @@ class GroupsController < ApplicationControllerif (term = params[:term]).present?groups =- groups.where("groups.name ILIKE :term OR groups.full_name ILIKE :term", term: "%#{term}%")+ groups.where(+ "position(LOWER(:term) IN LOWER(groups.name)) <> 0 OR position(LOWER(:term) IN LOWER(groups.full_name)) <> 0",+ term: term,+ )endgroups = groups.where(automatic: false) if params[:ignore_automatic].to_s == "true"