Software /
code /
prosody
Comparison
util/sasl.lua @ 507:4d3ccc6b5817
Automerge with waqas.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Sun, 30 Nov 2008 17:18:31 +0100 |
parent | 505:1b938e00412c |
parent | 504:efc5184effa1 |
child | 508:4fd60ae97535 |
comparison
equal
deleted
inserted
replaced
506:96f9f8dd9a45 | 507:4d3ccc6b5817 |
---|---|
2 local md5 = require "util.hashes".md5; | 2 local md5 = require "util.hashes".md5; |
3 local log = require "util.logger".init("sasl"); | 3 local log = require "util.logger".init("sasl"); |
4 local tostring = tostring; | 4 local tostring = tostring; |
5 local st = require "util.stanza"; | 5 local st = require "util.stanza"; |
6 local generate_uuid = require "util.uuid".generate; | 6 local generate_uuid = require "util.uuid".generate; |
7 local t_insert, t_concat = table.insert, table.concat; | |
8 local to_byte, to_char = string.byte, string.char; | |
7 local s_match = string.match; | 9 local s_match = string.match; |
8 local gmatch = string.gmatch | 10 local gmatch = string.gmatch |
9 local string = string | 11 local string = string |
10 local math = require "math" | 12 local math = require "math" |
11 local type = type | 13 local type = type |
64 if message["rspauth"] then data = data..[[rspauth=]]..message.rspauth.."," end | 66 if message["rspauth"] then data = data..[[rspauth=]]..message.rspauth.."," end |
65 data = data:gsub(",$", "") | 67 data = data:gsub(",$", "") |
66 return data | 68 return data |
67 end | 69 end |
68 | 70 |
71 local function latin1toutf8(str) | |
72 local p = {}; | |
73 for ch in gmatch(str, ".") do | |
74 ch = to_byte(ch); | |
75 if (ch < 0x80) then | |
76 t_insert(p, to_char(ch)); | |
77 elseif (ch < 0xC0) then | |
78 t_insert(p, to_char(0xC2, ch)); | |
79 else | |
80 t_insert(p, to_char(0xC3, ch - 64)); | |
81 end | |
82 end | |
83 return t_concat(p); | |
84 end | |
69 local function parse(data) | 85 local function parse(data) |
70 message = {} | 86 message = {} |
71 for k, v in gmatch(data, [[([%w%-]+)="?([^",]*)"?,?]]) do -- FIXME The hacky regex makes me shudder | 87 for k, v in gmatch(data, [[([%w%-]+)="?([^",]*)"?,?]]) do -- FIXME The hacky regex makes me shudder |
72 message[k] = v | 88 message[k] = v |
73 end | 89 end |