DEV: Use safer SQL function for string queries when searching groups (#26851)
... so that special characters in 'term' aren't interpreted by ILIKE.
This commit is contained in:
parent
f28742e597
commit
d937f5b098
|
@ -638,7 +638,10 @@ class GroupsController < ApplicationController
|
||||||
|
|
||||||
if (term = params[:term]).present?
|
if (term = params[:term]).present?
|
||||||
groups =
|
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,
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
groups = groups.where(automatic: false) if params[:ignore_automatic].to_s == "true"
|
groups = groups.where(automatic: false) if params[:ignore_automatic].to_s == "true"
|
||||||
|
|
Loading…
Reference in New Issue