Просмотр исходного кода

fix(clients api): use alternative base64 function for OTP 25

Fixes https://github.com/emqx/emqx/pull/12798#discussion_r1555524603
Thales Macedo Garitezi 1 год назад
Родитель
Сommit
ba96edb061

+ 3 - 3
apps/emqx_management/src/emqx_mgmt_api_clients.erl

@@ -1088,7 +1088,7 @@ next_ds_cursor(Iter) ->
     }.
 
 parse_cursor(CursorBin, Nodes) ->
-    try base64:decode(CursorBin, #{mode => urlsafe, padding => false}) of
+    try emqx_base62:decode(CursorBin) of
         Bin ->
             parse_cursor1(Bin, Nodes)
     catch
@@ -1133,11 +1133,11 @@ serialize_cursor(#{type := ?CURSOR_TYPE_ETS, node_idx := NodeIdx, cont := Cont})
         #{?CURSOR_ETS_NODE_IDX => NodeIdx, ?CURSOR_ETS_CONT => Cont}
     ],
     Bin = term_to_binary(Cursor0, [{compressed, 9}]),
-    base64:encode(Bin, #{mode => urlsafe, padding => false});
+    emqx_base62:encode(Bin);
 serialize_cursor(#{type := ?CURSOR_TYPE_DS, iterator := Iter}) ->
     Cursor0 = [?CURSOR_VSN1, ?CURSOR_TYPE_DS, Iter],
     Bin = term_to_binary(Cursor0, [{compressed, 9}]),
-    base64:encode(Bin, #{mode => urlsafe, padding => false}).
+    emqx_base62:encode(Bin).
 
 %% An adapter function so we can reutilize all the logic in `emqx_mgmt_api' for
 %% selecting/fuzzy filters, and also reutilize its BPAPI for selecting rows.

+ 1 - 1
apps/emqx_management/test/emqx_mgmt_api_clients_SUITE.erl

@@ -1673,7 +1673,7 @@ t_list_clients_v2(Config) ->
             %% Verify that a malicious cursor that could generate an atom on the node is
             %% rejected
             EvilAtomBin0 = <<131, 100, 0, 5, "some_atom_that_doesnt_exist_on_the_remote_node">>,
-            EvilAtomBin = base64:encode(EvilAtomBin0, #{mode => urlsafe, padding => false}),
+            EvilAtomBin = emqx_base62:encode(EvilAtomBin0),
 
             ?assertMatch(
                 {error, {{_, 400, _}, _, #{<<"message">> := <<"bad cursor">>}}},