Merge with Tobias
authorMatthew Wild <mwild1@gmail.com>
Sun, 30 Nov 2008 00:38:41 +0000 (00:38 +0000)
committerMatthew Wild <mwild1@gmail.com>
Sun, 30 Nov 2008 00:38:41 +0000 (00:38 +0000)
util/sasl.lua

index f1d01aedd1b1cddf4bf956eaa2aee725783e0639..fa818b9aaf198f46045a18fb8ae0d1a240895c7d 100644 (file)
@@ -12,6 +12,7 @@ local type = type
 local error = error
 local print = print
 local idna_ascii = require "util.encodings".idna.to_ascii
+local idna_unicode = require "util.encodings".idna.to_unicode
 
 module "sasl"
 
@@ -87,7 +88,7 @@ local function new_digest_md5(realm, password_handler)
                                                                                        qop = "auth",
                                                                                        charset = "utf-8",
                                                                                        algorithm = "md5-sess",
-                                                                                       realm = self.realm});
+                                                                                       realm = idna_ascii(self.realm)});
                        return "challenge", challenge
                elseif (self.step == 2) then
                        local response = parse(message)
@@ -126,7 +127,7 @@ local function new_digest_md5(realm, password_handler)
                        
                        --TODO maybe realm support
                        self.username = response["username"]
-                       local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5")
+                       local password_encoding, Y = self.password_handler(response["username"], idna_unicode(response["realm"]), "DIGEST-MD5")
                        if Y == nil then return "failure", "not-authorized"
                        elseif Y == false then return "failure", "account-disabled" end