fix(rule): replace sql crlf with spaces
get around the hocon bug: error handling escape character \n
This commit is contained in:
parent
5456a2efa1
commit
6cff53ad67
|
@ -189,6 +189,11 @@ param_path_id() ->
|
||||||
%% Rules API
|
%% Rules API
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
%% To get around the hocon bug, we replace crlf with spaces
|
||||||
|
replace_sql_clrf(#{ <<"sql">> := SQL } = Params) ->
|
||||||
|
NewSQL = re:replace(SQL, "[\r\n]", " ", [{return, binary}, global]),
|
||||||
|
Params#{<<"sql">> => NewSQL}.
|
||||||
|
|
||||||
'/rule_events'(get, _Params) ->
|
'/rule_events'(get, _Params) ->
|
||||||
{200, emqx_rule_events:event_info()}.
|
{200, emqx_rule_events:event_info()}.
|
||||||
|
|
||||||
|
@ -201,7 +206,7 @@ param_path_id() ->
|
||||||
<<>> ->
|
<<>> ->
|
||||||
{400, #{code => 'BAD_REQUEST', message => <<"empty rule id is not allowed">>}};
|
{400, #{code => 'BAD_REQUEST', message => <<"empty rule id is not allowed">>}};
|
||||||
Id ->
|
Id ->
|
||||||
Params = filter_out_request_body(Params0),
|
Params = filter_out_request_body(replace_sql_clrf(Params0)),
|
||||||
ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
|
ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
|
||||||
case emqx_rule_engine:get_rule(Id) of
|
case emqx_rule_engine:get_rule(Id) of
|
||||||
{ok, _Rule} ->
|
{ok, _Rule} ->
|
||||||
|
|
Loading…
Reference in New Issue