From 5841c8c0645e1ce573b00e68d5b44c8f7edcf93e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 17 Oct 2017 12:42:20 +0200 Subject: mod_mam: Load archiving preferes for offline users (fixes #1024) --- plugins/mod_mam/mamprefs.lib.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_mam/mamprefs.lib.lua b/plugins/mod_mam/mamprefs.lib.lua index 72c08886..1e05b9d1 100644 --- a/plugins/mod_mam/mamprefs.lib.lua +++ b/plugins/mod_mam/mamprefs.lib.lua @@ -33,9 +33,11 @@ local prefs = module:open_store(archive_store .. "_prefs"); local function get_prefs(user) local user_sessions = sessions[user]; local user_prefs = user_sessions and user_sessions.archive_prefs - if not user_prefs and user_sessions then + if not user_prefs then user_prefs = prefs:get(user); - user_sessions.archive_prefs = user_prefs; + if user_sessions then + user_sessions.archive_prefs = user_prefs; + end end return user_prefs or { [false] = global_default_policy }; end -- cgit v1.2.3 From c42b40b07d333623192e9f4747471aa07ec9a0b0 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 26 Oct 2017 22:22:14 +0200 Subject: mod_carbons: Synthesize a 'to' attribute for carbons of stanzas to "self" (fixes #956) --- plugins/mod_carbons.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_carbons.lua b/plugins/mod_carbons.lua index cb7d9233..1dcd4a07 100644 --- a/plugins/mod_carbons.lua +++ b/plugins/mod_carbons.lua @@ -76,6 +76,9 @@ local function message_handler(event, c2s) -- Create the carbon copy and wrap it as per the Stanza Forwarding XEP local copy = st.clone(stanza); + if c2s and not orig_to then + stanza.attr.to = bare_from; + end copy.attr.xmlns = "jabber:client"; local carbon = st.message{ from = bare_jid, type = orig_type, } :tag(c2s and "sent" or "received", { xmlns = xmlns_carbons }) -- cgit v1.2.3 From 44860ff0db890f17c857f579192e442beb8e78ff Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 27 Oct 2017 13:28:34 +0200 Subject: mod_http_errors: Set Content-Type header to HTML (fixes #1030) --- plugins/mod_http_errors.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_http_errors.lua b/plugins/mod_http_errors.lua index 17d357e5..d8646268 100644 --- a/plugins/mod_http_errors.lua +++ b/plugins/mod_http_errors.lua @@ -72,5 +72,8 @@ local function get_page(code, extra) end module:hook_object_event(server, "http-error", function (event) + if event.response then + event.response.headers.content_type = "text/html; charset=utf-8"; + end return get_page(event.code, (show_private and event.private_message) or event.message); end); -- cgit v1.2.3 From 78b88eff88e4f2817042777d5f46dff1252c2bec Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 27 Oct 2017 13:27:35 +0200 Subject: mod_http_errors: Use util.interpolation to render HTML template --- plugins/mod_http_errors.lua | 61 +++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 33 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_http_errors.lua b/plugins/mod_http_errors.lua index d8646268..13473219 100644 --- a/plugins/mod_http_errors.lua +++ b/plugins/mod_http_errors.lua @@ -2,6 +2,8 @@ module:set_global(); local server = require "net.http.server"; local codes = require "net.http.codes"; +local xml_escape = require "util.stanza".xml_escape; +local render = require "util.interpolation".new("%b{}", xml_escape); local show_private = module:get_option_boolean("http_errors_detailed", false); local always_serve = module:get_option_boolean("http_errors_always_show", true); @@ -21,53 +23,46 @@ local html = [[ - - + +{title} + -

$title

-

$message

-

$extra

+

{title}

+

{message}

+

{extra?}

]]; -html = html:gsub("%s%s+", ""); - -local entities = { - ["<"] = "<", [">"] = ">", ["&"] = "&", - ["'"] = "'", ["\""] = """, ["\n"] = "
", -}; - -local function tohtml(plain) - return (plain:gsub("[<>&'\"\n]", entities)); - -end local function get_page(code, extra) local message = messages[code]; if always_serve or message then message = message or default_message; - return (html:gsub("$(%a+)", { + return render(html, { title = rawget(codes, code) or ("Code "..tostring(code)); message = message[1]:gsub("%%", function () return message[math.random(2, math.max(#message,2))]; end); - extra = tohtml(extra or ""); - })); + extra = extra; + }); end end -- cgit v1.2.3