]> granicus.if.org Git - ejabberd/commitdiff
Simplify code for splitting auth string in cyrsasl
authorPaweł Chmielowski <pchmielowski@process-one.net>
Mon, 26 Feb 2018 08:36:56 +0000 (09:36 +0100)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Mon, 26 Feb 2018 08:36:56 +0000 (09:36 +0100)
This may fix problem from issue #2296

src/cyrsasl_plain.erl

index ec52b00a8477f00d990fe6629d393d3d1644c9b6..3bdcf8476ee99a31b19f6ad8e0793b328b53790a 100644 (file)
@@ -81,15 +81,8 @@ prepare(ClientIn) ->
       _ -> error
     end.
 
-parse(S) -> parse1(binary_to_list(S), "", []).
-
-parse1([0 | Cs], S, T) ->
-    parse1(Cs, "", [list_to_binary(lists:reverse(S)) | T]);
-parse1([C | Cs], S, T) -> parse1(Cs, [C | S], T);
-%parse1([], [], T) ->
-%    lists:reverse(T);
-parse1([], S, T) ->
-    lists:reverse([list_to_binary(lists:reverse(S)) | T]).
+parse(S) ->
+    binary:split(S, <<0>>, [global]).
 
 parse_domain(S) -> parse_domain1(binary_to_list(S), "", []).