aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2008-11-30 17:18:31 +0100
committerTobias Markmann <tm@ayena.de>2008-11-30 17:18:31 +0100
commite18e2e4b2dd9febe59224ea9a58e0ee1cbbbb80b (patch)
tree7f7e46548c10d40a1843c13580c827725fc47aa1 /util
parent81ff9d3a9fbaff5893deeacc854c25b61d3f6106 (diff)
parent8932fbc85ca4a43bba31099569bb579c6a803f22 (diff)
downloadprosody-e18e2e4b2dd9febe59224ea9a58e0ee1cbbbb80b.tar.gz
prosody-e18e2e4b2dd9febe59224ea9a58e0ee1cbbbb80b.zip
Automerge with waqas.
Diffstat (limited to 'util')
-rw-r--r--util/sasl.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/util/sasl.lua b/util/sasl.lua
index c39e714f..43340105 100644
--- a/util/sasl.lua
+++ b/util/sasl.lua
@@ -4,6 +4,8 @@ local log = require "util.logger".init("sasl");
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
@@ -66,6 +68,20 @@ local function new_digest_md5(realm, password_handler)
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