Merge pull request #7355 from EMQ-YangM/upstream_master

fix(rule): replace sql crlf with spaces
This commit is contained in:
Yang Miao 2022-03-21 21:15:15 +08:00 committed by GitHub
commit 79b8c63b54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -189,6 +189,11 @@ param_path_id() ->
%% 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) ->
{200, emqx_rule_events:event_info()}.
@ -201,7 +206,7 @@ param_path_id() ->
<<>> ->
{400, #{code => 'BAD_REQUEST', message => <<"empty rule id is not allowed">>}};
Id ->
Params = filter_out_request_body(Params0),
Params = filter_out_request_body(replace_sql_clrf(Params0)),
ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
case emqx_rule_engine:get_rule(Id) of
{ok, _Rule} ->