Skip to content

A platform for community discussion. Free, open, simple.

DEV: quote user input in GroupsController (#37636)

David Taylor681cc5d310de
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index e8caf75582f..1979848da9c 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -329,7 +329,7 @@ class GroupsController < ApplicationController
elsif include_custom_fields && params[:order] == "custom_field" &&
allowed_fields.include?(params[:order_field])
order =
- "(SELECT value FROM user_custom_fields ucf WHERE ucf.user_id = users.id AND ucf.name = '#{params[:order_field]}') #{dir} NULLS LAST"
+ "(SELECT value FROM user_custom_fields ucf WHERE ucf.user_id = users.id AND ucf.name = #{ActiveRecord::Base.connection.quote(params[:order_field])}) #{dir} NULLS LAST"
end
users = group.users.human_users