aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_carbons.lua3
-rw-r--r--plugins/mod_http_errors.lua64
-rw-r--r--plugins/mod_mam/mamprefs.lib.lua6
3 files changed, 38 insertions, 35 deletions
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 })
diff --git a/plugins/mod_http_errors.lua b/plugins/mod_http_errors.lua
index 17d357e5..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,56 +23,52 @@ local html = [[
<!DOCTYPE html>
<html>
<head>
- <meta charset="utf-8">
- <style>
- body{
- margin-top:14%;
- text-align:center;
- background-color:#F8F8F8;
- font-family:sans-serif;
- }
- h1{
- font-size:xx-large;
- }
- p{
- font-size:x-large;
- }
- p+p { font-size: large; font-family: courier }
- </style>
+<meta charset="utf-8">
+<title>{title}</title>
+<style>
+body{
+ margin-top:14%;
+ text-align:center;
+ background-color:#F8F8F8;
+ font-family:sans-serif;
+}
+h1{
+ font-size:xx-large;
+}
+p{
+ font-size:x-large;
+}
+p+p {
+ font-size:large;
+ font-family:courier;
+}
+</style>
</head>
<body>
- <h1>$title</h1>
- <p>$message</p>
- <p>$extra</p>
+<h1>{title}</h1>
+<p>{message}</p>
+<p>{extra?}</p>
</body>
</html>
]];
-html = html:gsub("%s%s+", "");
-
-local entities = {
- ["<"] = "&lt;", [">"] = "&gt;", ["&"] = "&amp;",
- ["'"] = "&apos;", ["\""] = "&quot;", ["\n"] = "<br/>",
-};
-
-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
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);
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