From 4915fb50442d5bf3536e5fffbb3a9f8886586bc0 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Thu, 14 Nov 2019 22:15:25 -0500 Subject: [PATCH] normalize search string in filter compilation --- lib/philomena_web/plugs/image_filter.ex | 3 ++- lib/search/string.ex | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/philomena_web/plugs/image_filter.ex b/lib/philomena_web/plugs/image_filter.ex index 2a6131ad..ce0f50a9 100644 --- a/lib/philomena_web/plugs/image_filter.ex +++ b/lib/philomena_web/plugs/image_filter.ex @@ -1,5 +1,6 @@ defmodule PhilomenaWeb.Plugs.ImageFilter do import Plug.Conn + import Search.String alias Philomena.Images.Query alias Pow.Plug @@ -13,7 +14,7 @@ defmodule PhilomenaWeb.Plugs.ImageFilter do filter = conn.assigns[:current_filter] tag_exclusion = %{terms: %{tag_ids: filter.hidden_tag_ids}} - {:ok, query_exclusion} = Query.compile(user, filter.hidden_complex_str) + {:ok, query_exclusion} = Query.compile(user, normalize(filter.hidden_complex_str)) query = %{ bool: %{ diff --git a/lib/search/string.ex b/lib/search/string.ex index adbe35c5..8437b784 100644 --- a/lib/search/string.ex +++ b/lib/search/string.ex @@ -1,4 +1,8 @@ defmodule Search.String do + def normalize(nil) do + "" + end + def normalize(str) do str |> String.replace("\r", "")