Software /
code /
prosody
Changeset
2263:ff881b857c98
util.sasl.plain: A little refactoring.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 29 Nov 2009 18:30:33 +0500 |
parents | 2262:83823ba8de40 |
children | 2264:49580a13f71e 2281:27441b099984 |
files | util/sasl/plain.lua |
diffstat | 1 files changed, 11 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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.";