Software /
code /
prosody
Changeset
3540:bc139431830b
Monster whitespace commit (beware the whitespace monster).
line wrap: on
line diff
--- a/core/certmanager.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/core/certmanager.lua Sat Oct 16 23:00:42 2010 +0500 @@ -69,8 +69,8 @@ else log("error", "SSL/TLS: Error initialising for host %s: %s", host, err ); end - end - return ctx, err; + end + return ctx, err; end function reload_ssl_config()
--- a/core/componentmanager.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/core/componentmanager.lua Sat Oct 16 23:00:42 2010 +0500 @@ -92,7 +92,7 @@ ssl_ctx_in = certmanager.create_context(host, "server"); end end - return { type = "component", host = host, connected = true, s2sout = {}, + return { type = "component", host = host, connected = true, s2sout = {}, ssl_ctx = ssl_ctx, ssl_ctx_in = ssl_ctx_in, events = events or events_new(), dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(), disallow_s2s = configmanager.get(host, "core", "disallow_s2s"); };
--- a/core/loggingmanager.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/core/loggingmanager.lua Sat Oct 16 23:00:42 2010 +0500 @@ -10,7 +10,7 @@ local format, rep = string.format, string.rep; local pcall = pcall; local debug = debug; -local tostring, setmetatable, rawset, pairs, ipairs, type = +local tostring, setmetatable, rawset, pairs, ipairs, type = tostring, setmetatable, rawset, pairs, ipairs, type; local io_open, io_write = io.open, io.write; local math_max, rep = math.max, string.rep; @@ -168,7 +168,7 @@ default_logging = { { to = "console" , levels = { min = (debug_mode and "debug") or "info" } } }; default_file_logging = { - { to = "file", levels = { min = (debug_mode and "debug") or "info" }, timestamps = true } + { to = "file", levels = { min = (debug_mode and "debug") or "info" }, timestamps = true } }; default_timestamp = "%b %d %H:%M:%S";
--- a/core/s2smanager.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/core/s2smanager.lua Sat Oct 16 23:00:42 2010 +0500 @@ -16,10 +16,8 @@ local format = string.format; local t_insert, t_sort = table.insert, table.sort; local get_traceback = debug.traceback; -local tostring, pairs, ipairs, getmetatable, newproxy, error, tonumber, - setmetatable - = tostring, pairs, ipairs, getmetatable, newproxy, error, tonumber, - setmetatable; +local tostring, pairs, ipairs, getmetatable, newproxy, error, tonumber, setmetatable + = tostring, pairs, ipairs, getmetatable, newproxy, error, tonumber, setmetatable; local idna_to_ascii = require "util.encodings".idna.to_ascii; local connlisteners_get = require "net.connlisteners".get;
--- a/core/usermanager.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/core/usermanager.lua Sat Oct 16 23:00:42 2010 +0500 @@ -50,11 +50,11 @@ host_session.users = new_null_provider(); end end); - host_session.users = new_null_provider(); -- Start with the default usermanager provider - local auth_provider = config.get(host, "core", "authentication") or default_provider; - if auth_provider ~= "null" then - modulemanager.load(host, "auth_"..auth_provider); - end + host_session.users = new_null_provider(); -- Start with the default usermanager provider + local auth_provider = config.get(host, "core", "authentication") or default_provider; + if auth_provider ~= "null" then + modulemanager.load(host, "auth_"..auth_provider); + end end; prosody.events.add_handler("host-activated", initialize_host, 100); prosody.events.add_handler("component-activated", initialize_host, 100);
--- a/core/xmlhandlers.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/core/xmlhandlers.lua Sat Oct 16 23:00:42 2010 +0500 @@ -68,8 +68,8 @@ attr[i] = nil; local ns, nm = k:match(ns_pattern); if nm ~= "" then - ns = ns_prefixes[ns]; - if ns then + ns = ns_prefixes[ns]; + if ns then attr[ns..":"..nm] = attr[k]; attr[k] = nil; end
--- a/net/connlisteners.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/net/connlisteners.lua Sat Oct 16 23:00:42 2010 +0500 @@ -13,8 +13,8 @@ local log = require "util.logger".init("connlisteners"); local tostring = tostring; -local dofile, pcall, error = - dofile, pcall, error +local dofile, pcall, error = + dofile, pcall, error module "connlisteners"
--- a/net/dns.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/net/dns.lua Sat Oct 16 23:00:42 2010 +0500 @@ -674,11 +674,11 @@ retry = socket.gettime() + self.delays[1] }; - -- remember the query + -- remember the query self.active[id] = self.active[id] or {}; self.active[id][question] = o; - -- remember which coroutine wants the answer + -- remember which coroutine wants the answer local co = coroutine.running(); if co then set(self.wanted, qclass, qtype, qname, co, true); @@ -738,7 +738,7 @@ end end end - + if num == self.best_server then self.best_server = self.best_server + 1; if self.best_server > #self.server then @@ -887,12 +887,12 @@ function resolver:lookup(qname, qtype, qclass) -- - - - - - - - - - lookup self:query (qname, qtype, qclass) while self:pulse() do - local recvt = {} - for i, s in ipairs(self.socket) do - recvt[i] = s - end - socket.select(recvt, nil, 4) - end + local recvt = {} + for i, s in ipairs(self.socket) do + recvt[i] = s + end + socket.select(recvt, nil, 4) + end --print(self.cache); return self:peek(qname, qtype, qclass); end
--- a/net/http.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/net/http.lua Sat Oct 16 23:00:42 2010 +0500 @@ -19,7 +19,7 @@ local t_insert, t_concat = table.insert, table.concat; local pairs, ipairs = pairs, ipairs; local tonumber, tostring, xpcall, select, debug_traceback, char, format = - tonumber, tostring, xpcall, select, debug.traceback, string.char, string.format; + tonumber, tostring, xpcall, select, debug.traceback, string.char, string.format; local log = require "util.logger".init("http"); @@ -46,10 +46,10 @@ end local function expectbody(reqt, code) - if reqt.method == "HEAD" then return nil end - if code == 204 or code == 304 or code == 301 then return nil end - if code >= 100 and code < 200 then return nil end - return 1 + if reqt.method == "HEAD" then return nil end + if code == 204 or code == 304 or code == 301 then return nil end + if code >= 100 and code < 200 then return nil end + return 1 end local function request_reader(request, data, startpos)
--- a/net/httpserver.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/net/httpserver.lua Sat Oct 16 23:00:42 2010 +0500 @@ -31,7 +31,7 @@ local default_handler; local function expectbody(reqt) - return reqt.method == "POST"; + return reqt.method == "POST"; end local function send_response(request, response) @@ -212,8 +212,8 @@ ssl.options = "no_sslv2"; end - new{ port = port, interface = interface, - base = base, handler = handle_request, + new{ port = port, interface = interface, + base = base, handler = handle_request, ssl = ssl, type = (ssl and "ssl") or "tcp" }; end end
--- a/net/xmppcomponent_listener.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/net/xmppcomponent_listener.lua Sat Oct 16 23:00:42 2010 +0500 @@ -67,13 +67,13 @@ function stream_callbacks.streamopened(session, attr) if config.get(attr.to, "core", "component_module") ~= "component" then - -- Trying to act as a component domain which + -- Trying to act as a component domain which -- hasn't been configured session:close{ condition = "host-unknown", text = tostring(attr.to).." does not match any configured external components" }; return; end - -- Note that we don't create the internal component + -- Note that we don't create the internal component -- until after the external component auths successfully session.host = attr.to;
--- a/plugins/adhoc/adhoc.lib.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/adhoc/adhoc.lib.lua Sat Oct 16 23:00:42 2010 +0500 @@ -46,7 +46,7 @@ stanza = st.error_reply(stanza, data.error.type, data.error.condition, data.error.message); origin.send(stanza); return true; - else + else cmdtag = command:cmdtag("executing", sessionid); end
--- a/plugins/mod_admin_adhoc.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_admin_adhoc.lua Sat Oct 16 23:00:42 2010 +0500 @@ -579,7 +579,7 @@ local get_user_password_desc = adhoc_new("Get User Password", "http://jabber.org/protocol/admin#get-user-password", get_user_password_handler, "admin"); local get_user_roster_desc = adhoc_new("Get User Roster","http://jabber.org/protocol/admin#get-user-roster", get_user_roster_handler, "admin"); local get_user_stats_desc = adhoc_new("Get User Statistics","http://jabber.org/protocol/admin#user-stats", get_user_stats_handler, "admin"); -local get_online_users_desc = adhoc_new("Get List of Online Users", "http://jabber.org/protocol/admin#get-online-users", get_online_users_command_handler, "admin"); +local get_online_users_desc = adhoc_new("Get List of Online Users", "http://jabber.org/protocol/admin#get-online-users", get_online_users_command_handler, "admin"); local list_modules_desc = adhoc_new("List loaded modules", "http://prosody.im/protocol/modules#list", list_modules_handler, "admin"); local load_module_desc = adhoc_new("Load module", "http://prosody.im/protocol/modules#load", load_module_handler, "admin"); local reload_modules_desc = adhoc_new("Reload module", "http://prosody.im/protocol/modules#reload", reload_modules_handler, "admin");
--- a/plugins/mod_component.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_component.lua Sat Oct 16 23:00:42 2010 +0500 @@ -59,7 +59,7 @@ -- If component not already created for this host, create one now if not hosts[session.host].connected then local send = session.send; - session.component_session = cm_register_component(session.host, function (_, data) + session.component_session = cm_register_component(session.host, function (_, data) if data.attr and data.attr.xmlns == "jabber:client" then data.attr.xmlns = nil; end
--- a/plugins/mod_compression.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_compression.lua Sat Oct 16 23:00:42 2010 +0500 @@ -39,7 +39,7 @@ module:hook("s2s-stream-features", function(event) local origin, features = event.origin, event.features; -- FIXME only advertise compression support when TLS layer has no compression enabled - if not origin.compressed then + if not origin.compressed then features:add_child(compression_stream_feature); end end);
--- a/plugins/mod_console.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_console.lua Sat Oct 16 23:00:42 2010 +0500 @@ -257,8 +257,8 @@ local hours = t%24; t = (t - hours)/24; local days = t; - return true, string.format("This server has been running for %d day%s, %d hour%s and %d minute%s (since %s)", - days, (days ~= 1 and "s") or "", hours, (hours ~= 1 and "s") or "", + return true, string.format("This server has been running for %d day%s, %d hour%s and %d minute%s (since %s)", + days, (days ~= 1 and "s") or "", hours, (hours ~= 1 and "s") or "", minutes, (minutes ~= 1 and "s") or "", os.date("%c", prosody.start_time)); end @@ -526,11 +526,11 @@ end end end - local subhost_filter = function (h) + local subhost_filter = function (h) return (match_jid and h:match(match_jid)); end for session in pairs(incoming_s2s) do - if session.to_host == host and ((not match_jid) or host:match(match_jid) + if session.to_host == host and ((not match_jid) or host:match(match_jid) or (session.from_host and session.from_host:match(match_jid)) -- Pft! is what I say to list comprehensions or (session.hosts and #array.collect(keys(session.hosts)):filter(subhost_filter)>0)) then @@ -573,7 +573,7 @@ if hosts[from] and not hosts[to] then -- Is an outgoing connection local session = hosts[from].s2sout[to]; - if not session then + if not session then print("No outgoing connection from "..from.." to "..to) else (session.close or s2smanager.destroy_session)(session);
--- a/plugins/mod_offline.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_offline.lua Sat Oct 16 23:00:42 2010 +0500 @@ -35,20 +35,20 @@ module:hook("message/offline/broadcast", function(event) local origin = event.origin; - if origin.priority >= 0 then - local node, host = origin.username, origin.host; - - local data = datamanager.list_load(node, host, "offline"); - if not data then return true; end - for _, stanza in ipairs(data) do - stanza = st.deserialize(stanza); - stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203 - stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated) - stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; - origin.send(stanza); - end - return true; - end + if origin.priority >= 0 then + local node, host = origin.username, origin.host; + + local data = datamanager.list_load(node, host, "offline"); + if not data then return true; end + for _, stanza in ipairs(data) do + stanza = st.deserialize(stanza); + stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203 + stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated) + stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; + origin.send(stanza); + end + return true; + end end); module:hook("message/offline/delete", function(event)
--- a/plugins/mod_posix.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_posix.lua Sat Oct 16 23:00:42 2010 +0500 @@ -111,7 +111,7 @@ end end -local syslog_opened +local syslog_opened; function syslog_sink_maker(config) if not syslog_opened then pposix.syslog_open("prosody"); @@ -119,12 +119,12 @@ end local syslog, format = pposix.syslog_log, string.format; return function (name, level, message, ...) - if ... then - syslog(level, format(message, ...)); - else - syslog(level, message); - end - end; + if ... then + syslog(level, format(message, ...)); + else + syslog(level, message); + end + end; end require "core.loggingmanager".register_sink_type("syslog", syslog_sink_maker);
--- a/plugins/mod_presence.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_presence.lua Sat Oct 16 23:00:42 2010 +0500 @@ -59,15 +59,15 @@ priority[1] = "0"; end end - local priority = stanza:child_with_name("priority"); - if priority and #priority > 0 then - priority = t_concat(priority); - if s_find(priority, "^[+-]?[0-9]+$") then - priority = tonumber(priority); - if priority < -128 then priority = -128 end - if priority > 127 then priority = 127 end - else priority = 0; end - else priority = 0; end + local priority = stanza:child_with_name("priority"); + if priority and #priority > 0 then + priority = t_concat(priority); + if s_find(priority, "^[+-]?[0-9]+$") then + priority = tonumber(priority); + if priority < -128 then priority = -128 end + if priority > 127 then priority = 127 end + else priority = 0; end + else priority = 0; end if full_sessions[origin.full_jid] then -- if user is still connected origin.send(stanza); -- reflect their presence back to them end @@ -115,15 +115,15 @@ end end - if priority >= 0 then - local offline = offlinemanager.load(node, host); - if offline then - for _, msg in ipairs(offline) do - origin.send(msg); -- FIXME do we need to modify to/from in any way? - end - offlinemanager.deleteAll(node, host); - end - end + if priority >= 0 then + local offline = offlinemanager.load(node, host); + if offline then + for _, msg in ipairs(offline) do + origin.send(msg); -- FIXME do we need to modify to/from in any way? + end + offlinemanager.deleteAll(node, host); + end + end end if stanza.attr.type == "unavailable" then origin.presence = nil;
--- a/plugins/mod_register.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_register.lua Sat Oct 16 23:00:42 2010 +0500 @@ -151,7 +151,7 @@ if usermanager_create_user(username, password, host) then session.send(st.reply(stanza)); -- user created! module:log("info", "User account created: %s@%s", username, host); - module:fire_event("user-registered", { + module:fire_event("user-registered", { username = username, host = host, source = "mod_register", session = session }); else
--- a/plugins/mod_roster.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_roster.lua Sat Oct 16 23:00:42 2010 +0500 @@ -63,7 +63,7 @@ else -- stanza.attr.type == "set" local query = stanza.tags[1]; if #query.tags == 1 and query.tags[1].name == "item" - and query.tags[1].attr.xmlns == "jabber:iq:roster" and query.tags[1].attr.jid + and query.tags[1].attr.xmlns == "jabber:iq:roster" and query.tags[1].attr.jid -- Protection against overwriting roster.pending, until we move it and query.tags[1].attr.jid ~= "pending" then local item = query.tags[1]; @@ -103,7 +103,7 @@ else r_item.subscription = "none"; end - for _, child in ipairs(item) do + for _, child in ipairs(item) do if child.name == "group" then local text = t_concat(child); if text and text ~= "" then
--- a/plugins/mod_uptime.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_uptime.lua Sat Oct 16 23:00:42 2010 +0500 @@ -34,8 +34,8 @@ local hours = t%24; t = (t - hours)/24; local days = t; - return string.format("This server has been running for %d day%s, %d hour%s and %d minute%s (since %s)", - days, (days ~= 1 and "s") or "", hours, (hours ~= 1 and "s") or "", + return string.format("This server has been running for %d day%s, %d hour%s and %d minute%s (since %s)", + days, (days ~= 1 and "s") or "", hours, (hours ~= 1 and "s") or "", minutes, (minutes ~= 1 and "s") or "", os.date("%c", prosody.start_time)); end
--- a/plugins/mod_watchregistrations.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_watchregistrations.lua Sat Oct 16 23:00:42 2010 +0500 @@ -9,7 +9,7 @@ local host = module:get_host(); -local registration_watchers = module:get_option("registration_watchers") +local registration_watchers = module:get_option("registration_watchers") or module:get_option("admins") or {}; local registration_alert = module:get_option("registration_notification") or "User $username just registered on $host from $ip"; @@ -21,7 +21,7 @@ module:log("debug", "Notifying of new registration"); local message = st.message{ type = "chat", from = host } :tag("body") - :text(registration_alert:gsub("%$(%w+)", + :text(registration_alert:gsub("%$(%w+)", function (v) return user[v] or user.session and user.session[v] or nil; end)); for _, jid in ipairs(registration_watchers) do
--- a/plugins/mod_welcome.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/mod_welcome.lua Sat Oct 16 23:00:42 2010 +0500 @@ -11,9 +11,9 @@ local st = require "util.stanza"; -module:hook("user-registered", +module:hook("user-registered", function (user) - local welcome_stanza = + local welcome_stanza = st.message({ to = user.username.."@"..user.host, from = host }) :tag("body"):text(welcome_text:gsub("$(%w+)", user)); core_route_stanza(hosts[host], welcome_stanza);
--- a/plugins/muc/muc.lib.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/plugins/muc/muc.lib.lua Sat Oct 16 23:00:42 2010 +0500 @@ -588,8 +588,8 @@ end local valid_whois = { - moderators = true, - anyone = true, + moderators = true, + anyone = true, } function room_mt:process_form(origin, stanza)
--- a/tests/test.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/tests/test.lua Sat Oct 16 23:00:42 2010 +0500 @@ -217,7 +217,7 @@ for line, active in pairs(lines_hit) do if active ~= nil then total_active_lines = total_active_lines + 1; end if coverage_file then - if active == false then coverage_file:write(fn, "|", line, "|", name or "", "|miss\n"); + if active == false then coverage_file:write(fn, "|", line, "|", name or "", "|miss\n"); else coverage_file:write(fn, "|", line, "|", name or "", "|", tostring(success), "\n"); end end end
--- a/tests/test_core_configmanager.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/tests/test_core_configmanager.lua Sat Oct 16 23:00:42 2010 +0500 @@ -29,7 +29,7 @@ function set(set, u) assert_equal(set("*"), false, "Set with no section/key"); - assert_equal(set("*", "set_test"), false, "Set with no key"); + assert_equal(set("*", "set_test"), false, "Set with no key"); assert_equal(set("*", "set_test", "testkey"), true, "Setting a nil global value"); assert_equal(set("*", "set_test", "testkey", 123), true, "Setting a global value");
--- a/tests/test_core_stanza_router.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/tests/test_core_stanza_router.lua Sat Oct 16 23:00:42 2010 +0500 @@ -66,7 +66,7 @@ function env.core_post_stanza(p_origin, p_stanza) assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct"); assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print()); - target_handled = true; + target_handled = true; end env.hosts = hosts; @@ -84,7 +84,7 @@ function env.core_route_stanza(p_origin, p_stanza) assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct"); assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print()); - target_routed = true; + target_routed = true; end function env.core_post_stanza(...) env.core_route_stanza(...); end @@ -104,7 +104,7 @@ function env.core_route_stanza(p_origin, p_stanza) assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct"); assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print()); - target_routed = true; + target_routed = true; end function env.core_post_stanza(...) @@ -129,7 +129,7 @@ function env.core_route_stanza(p_origin, p_stanza) assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct"); assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print()); - target_routed = true; + target_routed = true; end function env.core_post_stanza(...) @@ -151,7 +151,7 @@ function env.core_route_stanza(p_origin, p_stanza) assert_equal(p_origin, s2sin_session, "origin of handled stanza is not correct"); assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print()); - target_routed = true; + target_routed = true; end function env.core_post_stanza(...) @@ -173,7 +173,7 @@ function env.core_post_stanza(p_origin, p_stanza) assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct"); assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print()); - target_handled = true; + target_handled = true; end env.hosts = hosts;
--- a/tests/test_sasl.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/tests/test_sasl.lua Sat Oct 16 23:00:42 2010 +0500 @@ -8,30 +8,30 @@ --- WARNING! --- --- This file contains a mix of encodings below. +-- This file contains a mix of encodings below. -- Many editors will unquestioningly convert these for you. -- Please be careful :( (I recommend Scite) --------------------------------- -local gmatch = string.gmatch; -local t_concat, t_insert = table.concat, table.insert; -local to_byte, to_char = string.byte, string.char; +local gmatch = string.gmatch; +local t_concat, t_insert = table.concat, table.insert; +local to_byte, to_char = string.byte, string.char; local function _latin1toutf8(str) - if not str then return str; end - 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 + if not str then return str; end + 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 function latin1toutf8() local function assert_utf8(latin, utf8)
--- a/tests/test_util_multitable.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/tests/test_util_multitable.lua Sat Oct 16 23:00:42 2010 +0500 @@ -32,7 +32,7 @@ should_have[item] = nil; end if next(should_have) then - return false, "not-enough"; + return false, "not-enough"; end return true, "has-all"; end
--- a/tests/util/logger.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/tests/util/logger.lua Sat Oct 16 23:00:42 2010 +0500 @@ -33,7 +33,7 @@ local inf = debug.getinfo(3, 'Snl'); level = level .. ","..tostring(inf.short_src):match("[^/]*$")..":"..inf.currentline; end - if ... then + if ... then print(name, getstring(logstyles[level], level), format(message, ...)); else print(name, getstring(logstyles[level], level), message);
--- a/tools/xep227toprosody.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/tools/xep227toprosody.lua Sat Oct 16 23:00:42 2010 +0500 @@ -114,7 +114,7 @@ --print("message :"..ch:pretty_print()); local ret, err = dm.list_append(username, host, "offline", st.preserialize(ch)); print("["..(err or "success").."] stored offline message: " ..username.."@"..host.." - "..ch.attr.from); - end + end end
--- a/util/array.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/util/array.lua Sat Oct 16 23:00:42 2010 +0500 @@ -6,8 +6,8 @@ -- COPYING file in the source package for more information. -- -local t_insert, t_sort, t_remove, t_concat - = table.insert, table.sort, table.remove, table.concat; +local t_insert, t_sort, t_remove, t_concat + = table.insert, table.sort, table.remove, table.concat; local array = {}; local array_base = {};
--- a/util/broadcast.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/util/broadcast.lua Sat Oct 16 23:00:42 2010 +0500 @@ -7,8 +7,8 @@ -- -local ipairs, pairs, setmetatable, type = - ipairs, pairs, setmetatable, type; +local ipairs, pairs, setmetatable, type = + ipairs, pairs, setmetatable, type; module "pubsub"
--- a/util/dataforms.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/util/dataforms.lua Sat Oct 16 23:00:42 2010 +0500 @@ -126,7 +126,7 @@ return data; end -field_readers["text-single"] = +field_readers["text-single"] = function (field_tag) local value = field_tag:child_with_name("value"); if value then @@ -134,13 +134,13 @@ end end -field_readers["text-private"] = +field_readers["text-private"] = field_readers["text-single"]; field_readers["jid-single"] = field_readers["text-single"]; -field_readers["jid-multi"] = +field_readers["jid-multi"] = function (field_tag) local result = {}; for value_tag in field_tag:childtags() do @@ -151,7 +151,7 @@ return result; end -field_readers["text-multi"] = +field_readers["text-multi"] = function (field_tag) local result = {}; for value_tag in field_tag:childtags() do @@ -176,7 +176,7 @@ return result; end -field_readers["boolean"] = +field_readers["boolean"] = function (field_tag) local value = field_tag:child_with_name("value"); if value then @@ -185,10 +185,10 @@ else return false; end - end + end end -field_readers["hidden"] = +field_readers["hidden"] = function (field_tag) local value = field_tag:child_with_name("value"); if value then
--- a/util/hmac.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/util/hmac.lua Sat Oct 16 23:00:42 2010 +0500 @@ -40,7 +40,7 @@ blocksize the blocksize for the hash function in bytes hex - return raw hash or hexadecimal string + return raw hash or hexadecimal string --]] function hmac(key, message, hash, blocksize, hex) if #key > blocksize then
--- a/util/iterators.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/util/iterators.lua Sat Oct 16 23:00:42 2010 +0500 @@ -73,7 +73,7 @@ var = ret[1]; if var == nil then break; end x = x + 1; - end + end return x; end @@ -131,7 +131,7 @@ return t; end --- Treat the return of an iterator as key,value pairs, +-- Treat the return of an iterator as key,value pairs, -- and build a table function it2table(f, s, var) local t, var = {};
--- a/util/logger.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/util/logger.lua Sat Oct 16 23:00:42 2010 +0500 @@ -72,7 +72,7 @@ end -- To make sure our cached lengths stay in sync with reality - modify_hooks[logger] = function () num_level_handlers, num_source_handlers = #level_handlers, source_handlers and #source_handlers; end; + modify_hooks[logger] = function () num_level_handlers, num_source_handlers = #level_handlers, source_handlers and #source_handlers; end; return logger; end
--- a/util/sasl/scram.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/util/sasl/scram.lua Sat Oct 16 23:00:42 2010 +0500 @@ -67,7 +67,7 @@ -- hash algorithm independent Hi(PBKDF2) implementation function Hi(hmac, str, salt, i) local Ust = hmac(str, salt.."\0\0\0\1"); - local res = Ust; + local res = Ust; for n=1,i-1 do local Und = hmac(str, Ust) res = binaryXOR(res, Und) @@ -80,8 +80,8 @@ -- check for forbidden char sequences for eq in username:gmatch("=(.?.?)") do if eq ~= "2D" and eq ~= "3D" then - return false - end + return false + end end -- replace =2D with , and =3D with =
--- a/util/set.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/util/set.lua Sat Oct 16 23:00:42 2010 +0500 @@ -6,7 +6,7 @@ -- COPYING file in the source package for more information. -- -local ipairs, pairs, setmetatable, next, tostring = +local ipairs, pairs, setmetatable, next, tostring = ipairs, pairs, setmetatable, next, tostring; local t_concat = table.concat;
--- a/util/xmppstream.lua Sat Oct 16 08:34:32 2010 +0500 +++ b/util/xmppstream.lua Sat Oct 16 23:00:42 2010 +0500 @@ -69,8 +69,8 @@ attr[i] = nil; local ns, nm = k:match(ns_pattern); if nm ~= "" then - ns = ns_prefixes[ns]; - if ns then + ns = ns_prefixes[ns]; + if ns then attr[ns..":"..nm] = attr[k]; attr[k] = nil; end