prosodyctl: Fix import of util.iterators
[prosody.git] / util / sasl / scram.lua
index 530ef5a005614837b2edd440b9df120b8cc203a3..055ba16a7d551e3448e04358d34737b9b4b15b18 100644 (file)
@@ -24,7 +24,7 @@ local t_concat = table.concat;
 local char = string.char;
 local byte = string.byte;
 
-module "scram"
+module "sasl.scram"
 
 --=========================
 --SASL SCRAM-SHA-1 according to RFC 5802
@@ -79,18 +79,18 @@ end
 local function validate_username(username)
        -- check for forbidden char sequences
        for eq in username:gmatch("=(.?.?)") do
-               if eq ~= "2D" and eq ~= "3D" then
+               if eq ~= "2C" and eq ~= "3D" then
                        return false
                end
        end
        
-       -- replace =2D with , and =3D with =
-       username = username:gsub("=2D", ",");
+       -- replace =2C with , and =3D with =
+       username = username:gsub("=2C", ",");
        username = username:gsub("=3D", "=");
        
        -- apply SASLprep
        username = saslprep(username);
-       return username;
+       return username and #username>0 and username;
 end
 
 local function hashprep(hashname)