fix(authz): placeholder regular replace
This commit is contained in:
parent
060962700e
commit
d7c7292321
|
@ -68,6 +68,8 @@
|
|||
|
||||
-define(CONF_KEY_PATH, [authorization, sources]).
|
||||
|
||||
-define(RE_PLACEHOLDER, "\\$\\{[a-z0-9\\-]+\\}").
|
||||
|
||||
-define(USERNAME_RULES_EXAMPLE, #{username => user1,
|
||||
rules => [ #{topic => <<"test/toopic/1">>,
|
||||
permission => <<"allow">>,
|
||||
|
|
|
@ -38,10 +38,10 @@ description() ->
|
|||
parse_query(undefined) ->
|
||||
undefined;
|
||||
parse_query(Sql) ->
|
||||
case re:run(Sql, "'%[ucCad]'", [global, {capture, all, list}]) of
|
||||
case re:run(Sql, ?RE_PLACEHOLDER, [global, {capture, all, list}]) of
|
||||
{match, Variables} ->
|
||||
Params = [Var || [Var] <- Variables],
|
||||
{re:replace(Sql, "'%[ucCad]'", "?", [global, {return, list}]), Params};
|
||||
{re:replace(Sql, ?RE_PLACEHOLDER, "?", [global, {return, list}]), Params};
|
||||
nomatch ->
|
||||
{Sql, []}
|
||||
end.
|
||||
|
|
|
@ -38,7 +38,7 @@ description() ->
|
|||
parse_query(undefined) ->
|
||||
undefined;
|
||||
parse_query(Sql) ->
|
||||
case re:run(Sql, "'%[ucCad]'", [global, {capture, all, list}]) of
|
||||
case re:run(Sql, ?RE_PLACEHOLDER, [global, {capture, all, list}]) of
|
||||
{match, Variables} ->
|
||||
Params = [Var || [Var] <- Variables],
|
||||
Vars = ["$" ++ integer_to_list(I) || I <- lists:seq(1, length(Params))],
|
||||
|
|
Loading…
Reference in New Issue