fix(api): escape the searching string
This commit is contained in:
parent
4eb966549e
commit
2ded7fbe8c
|
@ -258,7 +258,7 @@ ms(lifetime, X) ->
|
|||
|
||||
fuzzy_filter_fun(Fuzzy) ->
|
||||
REFuzzy = lists:map(fun({K, like, S}) ->
|
||||
{ok, RE} = re:compile(S),
|
||||
{ok, RE} = re:compile(escape(S)),
|
||||
{K, like, RE}
|
||||
end, Fuzzy),
|
||||
fun(MsRaws) when is_list(MsRaws) ->
|
||||
|
@ -266,6 +266,9 @@ fuzzy_filter_fun(Fuzzy) ->
|
|||
, MsRaws)
|
||||
end.
|
||||
|
||||
escape(B) when is_binary(B) ->
|
||||
re:replace(B, <<"\\\\">>, <<"\\\\\\\\">>, [{return, binary}, global]).
|
||||
|
||||
run_fuzzy_filter(_, []) ->
|
||||
true;
|
||||
run_fuzzy_filter(E = {_, #{clientinfo := ClientInfo}, _}, [{Key, _, RE} | Fuzzy]) ->
|
||||
|
|
|
@ -620,7 +620,7 @@ ms(created_at, X) ->
|
|||
|
||||
fuzzy_filter_fun(Fuzzy) ->
|
||||
REFuzzy = lists:map(fun({K, like, S}) ->
|
||||
{ok, RE} = re:compile(S),
|
||||
{ok, RE} = re:compile(escape(S)),
|
||||
{K, like, RE}
|
||||
end, Fuzzy),
|
||||
fun(MsRaws) when is_list(MsRaws) ->
|
||||
|
@ -628,6 +628,9 @@ fuzzy_filter_fun(Fuzzy) ->
|
|||
, MsRaws)
|
||||
end.
|
||||
|
||||
escape(B) when is_binary(B) ->
|
||||
re:replace(B, <<"\\\\">>, <<"\\\\\\\\">>, [{return, binary}, global]).
|
||||
|
||||
run_fuzzy_filter(_, []) ->
|
||||
true;
|
||||
run_fuzzy_filter(E = {_, #{clientinfo := ClientInfo}, _}, [{Key, _, RE} | Fuzzy]) ->
|
||||
|
|
Loading…
Reference in New Issue