diff -r 83823ba8de40 -r ff881b857c98 util/sasl/plain.lua --- a/util/sasl/plain.lua Sun Nov 29 18:29:19 2009 +0500 +++ b/util/sasl/plain.lua Sun Nov 29 18:30:33 2009 +0500 @@ -17,26 +17,23 @@ module "plain" ---========================= ---SASL PLAIN according to RFC 4616 +-- ================================ +-- SASL PLAIN according to RFC 4616 local function plain(self, message) - local response = message - - local authorization, authentication, password; - if response then - authorization = s_match(response, "([^%z]+)") - authentication = s_match(response, "%z([^%z]+)%z") - password = s_match(response, "%z[^%z]+%z([^%z]+)") - end - - if authentication == nil or password == nil then + if not message then return "failure", "malformed-request"; end - + + local authorization, authentication, password = s_match(message, "^([^%z]+)%z([^%z]+)%z([^%z]+)"); + + if not authorization then + return "failure", "malformed-request"; + end + -- SASLprep password and authentication authentication = saslprep(authentication); password = saslprep(password); - + if (not password) or (password == "") or (not authentication) or (authentication == "") then log("debug", "Username or password violates SASLprep."); return "failure", "malformed-request", "Invalid username or password.";