summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2011-01-24 11:34:29 +0000
committerMatthew Sackman <matthew@rabbitmq.com>2011-01-24 11:34:29 +0000
commit96c2f66d3c261f88fef07c83706a2262a2838eaf (patch)
tree19763949aac9ae689d5eb47d639c4f24d4dc83ca
parentcd9c9debea1972307c0678f80fa7007ea7551a92 (diff)
parente66487e2706659d42d41a76132c822756dc5a72e (diff)
downloadrabbitmq-server-96c2f66d3c261f88fef07c83706a2262a2838eaf.tar.gz
Merging default into bug23602
-rw-r--r--src/rabbit_auth_mechanism_plain.erl22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/rabbit_auth_mechanism_plain.erl b/src/rabbit_auth_mechanism_plain.erl
index 7d9dcd20..63eff191 100644
--- a/src/rabbit_auth_mechanism_plain.erl
+++ b/src/rabbit_auth_mechanism_plain.erl
@@ -41,11 +41,17 @@ init(_Sock) ->
[].
handle_response(Response, _State) ->
- %% The '%%"' at the end of the next line is for Emacs
- case re:run(Response, "^\\0([^\\0]*)\\0([^\\0]*)$",%%"
- [{capture, all_but_first, binary}]) of
- {match, [User, Pass]} ->
- rabbit_access_control:check_user_pass_login(User, Pass);
- _ ->
- {protocol_error, "response ~p invalid", [Response]}
- end.
+ {User, Response1} = split_on_null(drop_leading_null(Response), []),
+ {Pass, _Response2} = split_on_null(Response1, []),
+ rabbit_access_control:check_user_pass_login(
+ list_to_binary(User), list_to_binary(Pass)).
+
+drop_leading_null(<<0:8, Rest/binary>>) ->
+ Rest.
+
+split_on_null(<<0:8, Rest/binary>>, Acc) ->
+ {lists:reverse(Acc), Rest};
+split_on_null(<<>>, Acc) ->
+ {lists:reverse(Acc), <<>>};
+split_on_null(<<C:8, Rest/binary>>, Acc) ->
+ split_on_null(Rest, [C | Acc]).