mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 07:39:39 +02:00
Sanitize input for ilike in Account::Entry.search (#988)
This commit is contained in:
parent
cdbca5aff3
commit
d0bc959bee
2 changed files with 4 additions and 1 deletions
|
@ -137,7 +137,7 @@ class Account::Entry < ApplicationRecord
|
|||
|
||||
def search(params)
|
||||
query = all
|
||||
query = query.where("account_entries.name ILIKE ?", "%#{params[:search]}%") if params[:search].present?
|
||||
query = query.where("account_entries.name ILIKE ?", "%#{sanitize_sql_like(params[:search])}%") if params[:search].present?
|
||||
query = query.where("account_entries.date >= ?", params[:start_date]) if params[:start_date].present?
|
||||
query = query.where("account_entries.date <= ?", params[:end_date]) if params[:end_date].present?
|
||||
|
||||
|
|
|
@ -62,6 +62,9 @@ class Account::EntryTest < ActiveSupport::TestCase
|
|||
params = params.merge(categories: [ category.name ], merchants: [ merchant.name ]) # transaction specific search param
|
||||
|
||||
assert_equal 1, family.entries.search(params).size
|
||||
|
||||
params = { search: "%" }
|
||||
assert_equal 0, family.entries.search(params).size
|
||||
end
|
||||
|
||||
test "can calculate total spending for a group of transactions" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue