Skip to content

Commit 526b033

Browse files
committed
Move search param guard to format_search_params!
Strip non-Hash search params at the controller level in format_search_params! instead of guarding in the ES query builder. This is consistent with how tags, filetypes, and size are already sanitized in the same method.
1 parent 7069f03 commit 526b033

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

app/controllers/concerns/search_products.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def format_search_params!
3333
if params[:size].is_a?(String)
3434
params[:size] = params[:size].to_i
3535
end
36+
37+
params.delete(:search) unless params[:search].is_a?(Hash)
3638
end
3739

3840
def offer_codes_search_feature_active?(params)

app/modules/product/searchable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def search_options(params)
363363
end
364364

365365
search_options = search_options.to_hash
366-
search_options[:query][:bool][:must] << params[:search] if params[:search].is_a?(Hash)
366+
search_options[:query][:bool][:must] << params[:search] if params[:search]
367367

368368
if (params[:ids].present? || params[:section].is_a?(SellerProfileSection)) && params[:sort] == ProductSortKey::PAGE_LAYOUT
369369
product_ids = params[:ids] || params[:section].shown_products

0 commit comments

Comments
 (0)