Automerge with waqas.
authorTobias Markmann <tm@ayena.de>
Sun, 30 Nov 2008 16:18:31 +0000 (17:18 +0100)
committerTobias Markmann <tm@ayena.de>
Sun, 30 Nov 2008 16:18:31 +0000 (17:18 +0100)
1  2 
util/sasl.lua

diff --combined util/sasl.lua
index 02d47719bda35c50a61cbadf260550aaa156d13d,c39e714f113192874646d367307b0bd7ab7273d4..43340105f6916e2a5b04cf20f504306972c82218
@@@ -4,8 -4,6 +4,8 @@@ local log = require "util.logger".init(
  local tostring = tostring;
  local st = require "util.stanza";
  local generate_uuid = require "util.uuid".generate;
 +local t_insert, t_concat = table.insert, table.concat;
 +local to_byte, to_char = string.byte, string.char;
  local s_match = string.match;
  local gmatch = string.gmatch
  local string = string
@@@ -68,20 -66,6 +68,20 @@@ local function new_digest_md5(realm, pa
                return data
        end
        
 +      local function latin1toutf8(str)
 +              local p = {};
 +              for ch in gmatch(str, ".") do
 +                      ch = to_byte(ch);
 +                      if (ch < 0x80) then
 +                              t_insert(p, to_char(ch));
 +                      elseif (ch < 0xC0) then
 +                              t_insert(p, to_char(0xC2, ch));
 +                      else
 +                              t_insert(p, to_char(0xC3, ch - 64));
 +                      end
 +              end
 +              return t_concat(p);
 +      end
        local function parse(data)
                message = {}
                for k, v in gmatch(data, [[([%w%-]+)="?([^",]*)"?,?]]) do -- FIXME The hacky regex makes me shudder
                                                                                        qop = "auth",
                                                                                        charset = "utf-8",
                                                                                        algorithm = "md5-sess",
-                                                                                       realm = idna_ascii(self.realm)});
+                                                                                       realm = self.realm});
                        return "challenge", challenge
                elseif (self.step == 2) then
                        local response = parse(message)
                        
                        --TODO maybe realm support
                        self.username = response["username"]
-                       local password_encoding, Y = self.password_handler(response["username"], idna_unicode(response["realm"]), "DIGEST-MD5")
+                       local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5")
                        if Y == nil then return "failure", "not-authorized"
                        elseif Y == false then return "failure", "account-disabled" end