fix(authz): fix a re:replace error when username is undefined

This commit is contained in:
zhanghongtong 2021-07-19 14:46:34 +08:00 committed by Rory Z
parent 120c2b8cdf
commit 358db0320b
1 changed files with 1 additions and 1 deletions

View File

@ -85,7 +85,7 @@ replvar(Str0, PubSub, Topic,
is_binary(Str0) ->
NTopic = emqx_http_lib:uri_encode(Topic),
Str1 = re:replace(Str0, "%c", Clientid, [global, {return, binary}]),
Str2 = re:replace(Str1, "%u", Username, [global, {return, binary}]),
Str2 = re:replace(Str1, "%u", bin(Username), [global, {return, binary}]),
Str3 = re:replace(Str2, "%a", inet_parse:ntoa(IpAddress), [global, {return, binary}]),
Str4 = re:replace(Str3, "%r", bin(Protocol), [global, {return, binary}]),
Str5 = re:replace(Str4, "%m", Mountpoint, [global, {return, binary}]),