|
17 | 17 |
|
18 | 18 | -export([user_login_authentication/2, user_login_authorization/2,
|
19 | 19 | check_vhost_access/3, check_resource_access/4, check_topic_access/4,
|
20 |
| - state_can_expire/0]). |
| 20 | + state_can_expire/0, format_multi_attr/1, format_multi_attr/2]). |
21 | 21 |
|
22 | 22 | -export([get_connections/0]).
|
23 | 23 |
|
@@ -699,14 +699,32 @@ get_attributes(AttrName, [#eldap_entry{attributes = A}|Rem]) ->
|
699 | 699 | get_attributes(AttrName, [_|Rem]) -> get_attributes(AttrName, Rem).
|
700 | 700 |
|
701 | 701 | %% Format multiple attribute values for logging
|
702 |
| -format_multi_attr(Attrs) -> |
703 |
| - format_multi_attr(io_lib:printable_list(Attrs), Attrs). |
704 |
| - |
| 702 | +%% The attribute can be: |
| 703 | +%% - an ascii string (Erlang recognizes it as a printable_list) |
| 704 | +%% - an non-ascii string (Erlang does not recognize it as a printable_list) |
| 705 | +%% - a list/array of strings, which may contain ascii only or non-ascii and ascii characters |
| 706 | +utf8_list_to_string(List) -> unicode:characters_to_list(list_to_binary(List)). |
| 707 | +join_utf8_list(Acc, Sep, List) -> Acc ++ utf8_list_to_string(List) ++ Sep. |
| 708 | + |
| 709 | +format_multi_attr_value(Acc, _Sep, []) -> Acc; |
| 710 | +format_multi_attr_value(Acc, Sep, [H|T]) when is_list(H) -> |
| 711 | + [H1|_T1] = H, |
| 712 | + case H1 of |
| 713 | + V when is_list(V) -> format_multi_attr_value(join_utf8_list(Acc, Sep, V), Sep, T); |
| 714 | + _ -> format_multi_attr_value(join_utf8_list(Acc, Sep, H), Sep, T) |
| 715 | + end; |
| 716 | +format_multi_attr_value(Acc, Sep, List) -> join_utf8_list(Acc, Sep, List). |
| 717 | + |
| 718 | +format_multi_attr(Attrs) -> format_multi_attr(io_lib:printable_list(Attrs), Attrs). |
705 | 719 | format_multi_attr(true, Attrs) -> Attrs;
|
706 |
| -format_multi_attr(_, Attrs) when is_list(Attrs) -> string:join(Attrs, "; "); |
| 720 | +format_multi_attr(_, Attrs) when is_list(Attrs) -> |
| 721 | + [H|_T] = Attrs, |
| 722 | + case H of |
| 723 | + V when is_list(V) -> format_multi_attr_value("", "; ", Attrs); |
| 724 | + _ -> utf8_list_to_string(Attrs) |
| 725 | + end; |
707 | 726 | format_multi_attr(_, Error) -> Error.
|
708 | 727 |
|
709 |
| - |
710 | 728 | %% In case of multiple attributes, check for equality bi-directionally
|
711 | 729 | is_multi_attr_member(Str1, Str2) ->
|
712 | 730 | lists:member(Str1, Str2) orelse lists:member(Str2, Str1).
|
|
0 commit comments