From b7e51a203d3d95961294c711ae0d9c449ddb040d Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 16 Oct 2010 23:00:42 +0500 Subject: Monster whitespace commit (beware the whitespace monster). --- core/certmanager.lua | 4 ++-- core/componentmanager.lua | 2 +- core/loggingmanager.lua | 4 ++-- core/s2smanager.lua | 6 ++---- core/usermanager.lua | 10 +++++----- core/xmlhandlers.lua | 4 ++-- net/connlisteners.lua | 4 ++-- net/dns.lua | 18 +++++++++--------- net/http.lua | 10 +++++----- net/httpserver.lua | 6 +++--- net/xmppcomponent_listener.lua | 4 ++-- plugins/adhoc/adhoc.lib.lua | 2 +- plugins/mod_admin_adhoc.lua | 2 +- plugins/mod_component.lua | 2 +- plugins/mod_compression.lua | 2 +- plugins/mod_console.lua | 10 +++++----- plugins/mod_offline.lua | 28 ++++++++++++++-------------- plugins/mod_posix.lua | 14 +++++++------- plugins/mod_presence.lua | 36 ++++++++++++++++++------------------ plugins/mod_register.lua | 2 +- plugins/mod_roster.lua | 4 ++-- plugins/mod_uptime.lua | 4 ++-- plugins/mod_watchregistrations.lua | 4 ++-- plugins/mod_welcome.lua | 4 ++-- plugins/muc/muc.lib.lua | 4 ++-- tests/test.lua | 2 +- tests/test_core_configmanager.lua | 2 +- tests/test_core_stanza_router.lua | 12 ++++++------ tests/test_sasl.lua | 36 ++++++++++++++++++------------------ tests/test_util_multitable.lua | 2 +- tests/util/logger.lua | 2 +- tools/xep227toprosody.lua | 2 +- util/array.lua | 4 ++-- util/broadcast.lua | 4 ++-- util/dataforms.lua | 14 +++++++------- util/hmac.lua | 2 +- util/iterators.lua | 4 ++-- util/logger.lua | 2 +- util/sasl/scram.lua | 6 +++--- util/set.lua | 2 +- util/xmppstream.lua | 4 ++-- util/ztact.lua | 2 +- 42 files changed, 145 insertions(+), 147 deletions(-) diff --git a/core/certmanager.lua b/core/certmanager.lua index eadddd78..3f7bb348 100644 --- a/core/certmanager.lua +++ b/core/certmanager.lua @@ -69,8 +69,8 @@ function create_context(host, mode, config) 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() diff --git a/core/componentmanager.lua b/core/componentmanager.lua index 14d9c06d..6e06ae82 100644 --- a/core/componentmanager.lua +++ b/core/componentmanager.lua @@ -92,7 +92,7 @@ function create_component(host, component, events) 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"); }; diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua index 96cd32dc..3cd09431 100644 --- a/core/loggingmanager.lua +++ b/core/loggingmanager.lua @@ -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 @@ function reload_logging() 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"; diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 0ad8f83b..c4a94682 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -16,10 +16,8 @@ local socket = require "socket"; 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; diff --git a/core/usermanager.lua b/core/usermanager.lua index 5fc4a822..153be63e 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -50,11 +50,11 @@ function initialize_host(host) 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); diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index b7992f77..182da894 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -68,8 +68,8 @@ function init_xmlhandlers(session, stream_callbacks) 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 diff --git a/net/connlisteners.lua b/net/connlisteners.lua index 93dce8b3..e13f85de 100644 --- a/net/connlisteners.lua +++ b/net/connlisteners.lua @@ -13,8 +13,8 @@ local server = require "net.server"; 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" diff --git a/net/dns.lua b/net/dns.lua index 29d9cf36..d40174df 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -674,11 +674,11 @@ function resolver:query(qname, qtype, qclass) -- - - - - - - - - - -- query 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 @@ function resolver:servfail(sock) 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 @@ end 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 diff --git a/net/http.lua b/net/http.lua index 11407c4d..63ae31ad 100644 --- a/net/http.lua +++ b/net/http.lua @@ -19,7 +19,7 @@ local listener = connlisteners_get("httpclient") or error("No httpclient listene 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 @@ function formencode(form) 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) diff --git a/net/httpserver.lua b/net/httpserver.lua index b6a080b6..ca830a5a 100644 --- a/net/httpserver.lua +++ b/net/httpserver.lua @@ -31,7 +31,7 @@ module "httpserver" 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 @@ function new_from_config(ports, handle_request, default_options) 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 diff --git a/net/xmppcomponent_listener.lua b/net/xmppcomponent_listener.lua index 6f02b136..a96a1cff 100644 --- a/net/xmppcomponent_listener.lua +++ b/net/xmppcomponent_listener.lua @@ -67,13 +67,13 @@ end 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; diff --git a/plugins/adhoc/adhoc.lib.lua b/plugins/adhoc/adhoc.lib.lua index d4ffd80c..0cb4efe1 100644 --- a/plugins/adhoc/adhoc.lib.lua +++ b/plugins/adhoc/adhoc.lib.lua @@ -46,7 +46,7 @@ function _M.handle_cmd(command, origin, stanza) 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 diff --git a/plugins/mod_admin_adhoc.lua b/plugins/mod_admin_adhoc.lua index 37930c01..9ddb3b9f 100644 --- a/plugins/mod_admin_adhoc.lua +++ b/plugins/mod_admin_adhoc.lua @@ -579,7 +579,7 @@ local end_user_session_desc = adhoc_new("End User Session", "http://jabber.org/p 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"); diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua index 022792cf..1de576a0 100644 --- a/plugins/mod_component.lua +++ b/plugins/mod_component.lua @@ -59,7 +59,7 @@ function handle_component_auth(event) -- 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 diff --git a/plugins/mod_compression.lua b/plugins/mod_compression.lua index b5e273fd..82403016 100644 --- a/plugins/mod_compression.lua +++ b/plugins/mod_compression.lua @@ -39,7 +39,7 @@ end); 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); diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua index 9972e420..ba19c42e 100644 --- a/plugins/mod_console.lua +++ b/plugins/mod_console.lua @@ -257,8 +257,8 @@ function def_env.server:uptime() 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 @@ function def_env.s2s:show(match_jid) 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 @@ function def_env.s2s:close(from, to) 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); diff --git a/plugins/mod_offline.lua b/plugins/mod_offline.lua index edd14190..a3ca21d0 100644 --- a/plugins/mod_offline.lua +++ b/plugins/mod_offline.lua @@ -35,20 +35,20 @@ end); 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) diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index cb504787..e86b7854 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -111,7 +111,7 @@ local function write_pidfile() 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 @@ function syslog_sink_maker(config) 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); diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index ab2cac38..65abe665 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -59,15 +59,15 @@ function handle_normal_presence(origin, stanza) 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 @@ function handle_normal_presence(origin, stanza) 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; diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index 1e916e73..1df73297 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -151,7 +151,7 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event) 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 diff --git a/plugins/mod_roster.lua b/plugins/mod_roster.lua index 2eb70df3..fe2eea71 100644 --- a/plugins/mod_roster.lua +++ b/plugins/mod_roster.lua @@ -63,7 +63,7 @@ module:hook("iq/self/jabber:iq:roster:query", function(event) 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 @@ module:hook("iq/self/jabber:iq:roster:query", function(event) 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 diff --git a/plugins/mod_uptime.lua b/plugins/mod_uptime.lua index c3860af6..52b33c74 100644 --- a/plugins/mod_uptime.lua +++ b/plugins/mod_uptime.lua @@ -34,8 +34,8 @@ function uptime_text() 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 diff --git a/plugins/mod_watchregistrations.lua b/plugins/mod_watchregistrations.lua index f006818e..ac1e6302 100644 --- a/plugins/mod_watchregistrations.lua +++ b/plugins/mod_watchregistrations.lua @@ -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:hook("user-registered", 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 diff --git a/plugins/mod_welcome.lua b/plugins/mod_welcome.lua index 8f92010a..8f9cca2a 100644 --- a/plugins/mod_welcome.lua +++ b/plugins/mod_welcome.lua @@ -11,9 +11,9 @@ local welcome_text = module:get_option("welcome_message") or "Hello $username, w 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); diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 4a8ad922..89bd1304 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -588,8 +588,8 @@ function room_mt:send_form(origin, stanza) end local valid_whois = { - moderators = true, - anyone = true, + moderators = true, + anyone = true, } function room_mt:process_form(origin, stanza) diff --git a/tests/test.lua b/tests/test.lua index bb9bc876..ae5b24f0 100644 --- a/tests/test.lua +++ b/tests/test.lua @@ -217,7 +217,7 @@ function new_line_coverage_monitor(file) 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 diff --git a/tests/test_core_configmanager.lua b/tests/test_core_configmanager.lua index c4ed746f..132dfc74 100644 --- a/tests/test_core_configmanager.lua +++ b/tests/test_core_configmanager.lua @@ -29,7 +29,7 @@ end 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"); diff --git a/tests/test_core_stanza_router.lua b/tests/test_core_stanza_router.lua index 97dc2e19..0a93694f 100644 --- a/tests/test_core_stanza_router.lua +++ b/tests/test_core_stanza_router.lua @@ -66,7 +66,7 @@ function core_process_stanza(core_process_stanza, u) 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 core_process_stanza(core_process_stanza, u) 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 core_process_stanza(core_process_stanza, u) 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 core_process_stanza(core_process_stanza, u) 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 core_process_stanza(core_process_stanza, u) 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 core_process_stanza(core_process_stanza, u) 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; diff --git a/tests/test_sasl.lua b/tests/test_sasl.lua index 7c0b02f8..8bd1a2ff 100644 --- a/tests/test_sasl.lua +++ b/tests/test_sasl.lua @@ -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) diff --git a/tests/test_util_multitable.lua b/tests/test_util_multitable.lua index 4b7e4fcc..ed10b128 100644 --- a/tests/test_util_multitable.lua +++ b/tests/test_util_multitable.lua @@ -32,7 +32,7 @@ function get(get, multitable) should_have[item] = nil; end if next(should_have) then - return false, "not-enough"; + return false, "not-enough"; end return true, "has-all"; end diff --git a/tests/util/logger.lua b/tests/util/logger.lua index e62a1aa8..35facd4e 100644 --- a/tests/util/logger.lua +++ b/tests/util/logger.lua @@ -33,7 +33,7 @@ function init(name) 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); diff --git a/tools/xep227toprosody.lua b/tools/xep227toprosody.lua index 313b2194..bfe06c48 100755 --- a/tools/xep227toprosody.lua +++ b/tools/xep227toprosody.lua @@ -114,7 +114,7 @@ function store_offline_messages(username, host, offline_messages) --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 diff --git a/util/array.lua b/util/array.lua index 98c0ebe8..6c1f0460 100644 --- a/util/array.lua +++ b/util/array.lua @@ -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 = {}; diff --git a/util/broadcast.lua b/util/broadcast.lua index c74bf4e1..be17461d 100644 --- a/util/broadcast.lua +++ b/util/broadcast.lua @@ -7,8 +7,8 @@ -- -local ipairs, pairs, setmetatable, type = - ipairs, pairs, setmetatable, type; +local ipairs, pairs, setmetatable, type = + ipairs, pairs, setmetatable, type; module "pubsub" diff --git a/util/dataforms.lua b/util/dataforms.lua index 7814ada0..ae745e03 100644 --- a/util/dataforms.lua +++ b/util/dataforms.lua @@ -126,7 +126,7 @@ function form_t.data(layout, stanza) 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 @@ field_readers["text-single"] = 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 @@ field_readers["jid-multi"] = 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 @@ field_readers["list-multi"] = 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 @@ field_readers["boolean"] = 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 diff --git a/util/hmac.lua b/util/hmac.lua index 66dd41d8..6df6986e 100644 --- a/util/hmac.lua +++ b/util/hmac.lua @@ -40,7 +40,7 @@ hash 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 diff --git a/util/iterators.lua b/util/iterators.lua index cc504827..dc692d64 100644 --- a/util/iterators.lua +++ b/util/iterators.lua @@ -73,7 +73,7 @@ function count(f, s, var) var = ret[1]; if var == nil then break; end x = x + 1; - end + end return x; end @@ -131,7 +131,7 @@ function it2array(f, s, var) 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 = {}; diff --git a/util/logger.lua b/util/logger.lua index 80b5bcd0..1fbd4977 100644 --- a/util/logger.lua +++ b/util/logger.lua @@ -72,7 +72,7 @@ function make_logger(source_name, level) 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 diff --git a/util/sasl/scram.lua b/util/sasl/scram.lua index 7354c8fc..c846a7d1 100644 --- a/util/sasl/scram.lua +++ b/util/sasl/scram.lua @@ -67,7 +67,7 @@ end -- 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 @@ local function validate_username(username) -- 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 = diff --git a/util/set.lua b/util/set.lua index ee154ece..e4cc2dff 100644 --- a/util/set.lua +++ b/util/set.lua @@ -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; diff --git a/util/xmppstream.lua b/util/xmppstream.lua index d22c923b..2f232fd8 100644 --- a/util/xmppstream.lua +++ b/util/xmppstream.lua @@ -69,8 +69,8 @@ function new_sax_handlers(session, stream_callbacks) 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 diff --git a/util/ztact.lua b/util/ztact.lua index 2507bf8e..40aa8843 100644 --- a/util/ztact.lua +++ b/util/ztact.lua @@ -347,7 +347,7 @@ function lson_encode (mixed, f, indent, indents) --------------- lson_encode f ('[') f (lson_encode (k)) f ('] = ') lson_encode (v, f, indent+1, indents) f (',') - end + end f (' }') end end end -- cgit v1.2.3