# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1249910968 -3600
# Node ID 0baa849761b6d0104b01d0ab1d6e4cc15dff9173
# Parent  dc42bf326713a8c5ddbe63e63be71d3f5c0dca00# Parent  1fe566011e2bab3e243d8083b90ad7f9976faaae
Merge with Tobias

diff -r dc42bf326713 -r 0baa849761b6 util/sasl.lua
--- a/util/sasl.lua	Sun Aug 09 17:47:26 2009 +0500
+++ b/util/sasl.lua	Mon Aug 10 14:29:28 2009 +0100
@@ -70,11 +70,11 @@
 		if type(message) ~= "table" then error("serialize needs an argument of type table.") end
 
 		-- testing all possible values
+		if message["realm"] then data = data..[[realm="]]..message.realm..[[",]] end
 		if message["nonce"] then data = data..[[nonce="]]..message.nonce..[[",]] end
 		if message["qop"] then data = data..[[qop="]]..message.qop..[[",]] end
 		if message["charset"] then data = data..[[charset=]]..message.charset.."," end
 		if message["algorithm"] then data = data..[[algorithm=]]..message.algorithm.."," end
-		if message["realm"] then data = data..[[realm="]]..message.realm..[[",]] end
 		if message["rspauth"] then data = data..[[rspauth=]]..message.rspauth.."," end
 		data = data:gsub(",$", "")
 		return data
@@ -198,7 +198,7 @@
 
 			--TODO maybe realm support
 			self.username = response["username"];
-			local password_encoding, Y = self.credentials_handler("DIGEST-MD5", response["username"], to_unicode(domain), response["realm"], decoder);
+			local password_encoding, Y = self.credentials_handler("DIGEST-MD5", response["username"], self.realm, response["realm"], decoder);
 			if Y == nil then return "failure", "not-authorized"
 			elseif Y == false then return "failure", "account-disabled" end
 			local A1 = "";