util.sasl.plain: Fail gracefully on empty <auth/> tag
authorMatthew Wild <mwild1@gmail.com>
Sat, 28 Nov 2009 15:12:43 +0000 (15:12 +0000)
committerMatthew Wild <mwild1@gmail.com>
Sat, 28 Nov 2009 15:12:43 +0000 (15:12 +0000)
util/sasl/plain.lua

index 46a86bb92ef65239535756a58a53dcd1c5de65f1..9ebfa15d8537a162466610b56012f9938788d3ef 100644 (file)
@@ -21,10 +21,14 @@ module "plain"
 --SASL PLAIN according to RFC 4616
 local function plain(self, message)
        local response = message
-       local authorization = s_match(response, "([^%z]+)")
-       local authentication = s_match(response, "%z([^%z]+)%z")
-       local password = s_match(response, "%z[^%z]+%z([^%z]+)")
-
+       
+       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
                return "failure", "malformed-request";
        end
@@ -63,4 +67,4 @@ function init(registerMechanism)
        registerMechanism("PLAIN", {"plain", "plain_test"}, plain);
 end
 
-return _M;
\ No newline at end of file
+return _M;