fix(authn): no longer use single quotes to wrap placeholders
This commit is contained in:
parent
3a834a822f
commit
e071a10fee
|
@ -145,7 +145,7 @@ parse_query(Query) ->
|
||||||
case re:run(Query, ?RE_PLACEHOLDER, [global, {capture, all, binary}]) of
|
case re:run(Query, ?RE_PLACEHOLDER, [global, {capture, all, binary}]) of
|
||||||
{match, Captured} ->
|
{match, Captured} ->
|
||||||
PlaceHolders = [PlaceHolder || [PlaceHolder] <- Captured],
|
PlaceHolders = [PlaceHolder || [PlaceHolder] <- Captured],
|
||||||
NQuery = re:replace(Query, "'\\$\\{[a-z0-9\\-]+\\}'", "?", [global, {return, binary}]),
|
NQuery = re:replace(Query, ?RE_PLACEHOLDER, "?", [global, {return, binary}]),
|
||||||
{NQuery, PlaceHolders};
|
{NQuery, PlaceHolders};
|
||||||
nomatch ->
|
nomatch ->
|
||||||
{Query, []}
|
{Query, []}
|
||||||
|
|
|
@ -137,7 +137,7 @@ parse_query(Query) ->
|
||||||
PlaceHolders = [PlaceHolder || [PlaceHolder] <- Captured],
|
PlaceHolders = [PlaceHolder || [PlaceHolder] <- Captured],
|
||||||
Replacements = ["$" ++ integer_to_list(I) || I <- lists:seq(1, length(Captured))],
|
Replacements = ["$" ++ integer_to_list(I) || I <- lists:seq(1, length(Captured))],
|
||||||
NQuery = lists:foldl(fun({PlaceHolder, Replacement}, Query0) ->
|
NQuery = lists:foldl(fun({PlaceHolder, Replacement}, Query0) ->
|
||||||
re:replace(Query0, <<"'\\", PlaceHolder/binary, "'">>, Replacement, [{return, binary}])
|
re:replace(Query0, PlaceHolder, Replacement, [{return, binary}])
|
||||||
end, Query, lists:zip(PlaceHolders, Replacements)),
|
end, Query, lists:zip(PlaceHolders, Replacements)),
|
||||||
{NQuery, PlaceHolders};
|
{NQuery, PlaceHolders};
|
||||||
nomatch ->
|
nomatch ->
|
||||||
|
|
Loading…
Reference in New Issue