-
-
Notifications
You must be signed in to change notification settings - Fork 827
Closed
Description
When normalizing attributes using the new ActiveRecord::normalizes method, % could be tampered with.
class User < ActiveRecord::Base
normalizes :name, with: ->(name) { name.gsub(/[^a-z0-9]/, '_') }
end
User.ransack({ name_cont: 'foo' }).result.to_sql
# => "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"name\" LIKE '_foo_'"
# ^ ^
# %foo%In my opinion, this should not be possible as normalizes should only apply to the attribute itself and the search term but not the wildcards.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels