aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-10-29 02:05:19 +0200
committerKim Alvefur <zash@zash.se>2017-10-29 02:05:19 +0200
commit89526be11ca68bf639927c4ed1bc808bb769f5f5 (patch)
tree0d8a66dad4d8c64d5cfab32c11132b2c0e1ca301
parent62eaaff226249e924494f78434c422bd094264c1 (diff)
parent63e10c1c271e70eafc4257a54b07178488e33de1 (diff)
downloadprosody-89526be11ca68bf639927c4ed1bc808bb769f5f5.tar.gz
prosody-89526be11ca68bf639927c4ed1bc808bb769f5f5.zip
Merge 0.10->trunk
-rw-r--r--core/loggingmanager.lua2
-rw-r--r--core/rostermanager.lua9
-rw-r--r--man/prosodyctl.man14
-rw-r--r--man/prosodyctl.markdown14
-rw-r--r--net/http/server.lua8
-rw-r--r--plugins/mod_carbons.lua3
-rw-r--r--plugins/mod_http_errors.lua64
-rw-r--r--plugins/mod_mam/mamprefs.lib.lua6
8 files changed, 64 insertions, 56 deletions
diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua
index 6dc1c1d1..004f4c3b 100644
--- a/core/loggingmanager.lua
+++ b/core/loggingmanager.lua
@@ -178,7 +178,7 @@ local function log_to_file(sink_config, logfile)
local timestamps = sink_config.timestamps;
- if timestamps == true then
+ if timestamps == true or timestamps == nil then
timestamps = default_timestamp; -- Default format
elseif timestamps then
timestamps = timestamps .. " ";
diff --git a/core/rostermanager.lua b/core/rostermanager.lua
index c94482c4..f6a44028 100644
--- a/core/rostermanager.lua
+++ b/core/rostermanager.lua
@@ -104,9 +104,9 @@ local function load_roster(username, host)
if user then
roster = user.roster;
if roster then return roster; end
- log("debug", "load_roster: loading for new user: %s@%s", username, host);
+ log("debug", "load_roster: loading for new user: %s", jid);
else -- Attempt to load roster for non-loaded user
- log("debug", "load_roster: loading for offline user: %s@%s", username, host);
+ log("debug", "load_roster: loading for offline user: %s", jid);
end
local roster_store = storagemanager.open(host, "roster", "keyval");
local data, err = roster_store:get(username);
@@ -115,7 +115,10 @@ local function load_roster(username, host)
roster_metadata(roster, err);
if roster[jid] then
roster[jid] = nil;
- log("warn", "roster for %s has a self-contact", jid);
+ log("debug", "Roster for %s had a self-contact, removing", jid);
+ if not save_roster(username, host, roster, jid) then
+ log("warn", "Could not remove self-contact from roster for %s", jid);
+ end
end
if not err then
hosts[host].events.fire_event("roster-load", { username = username, host = host, roster = roster });
diff --git a/man/prosodyctl.man b/man/prosodyctl.man
index 3ea42cdd..0d3cf5d6 100644
--- a/man/prosodyctl.man
+++ b/man/prosodyctl.man
@@ -93,33 +93,33 @@ and private keys for use with Prosody.
Commands are of the form \f[C]prosodyctl\ cert\ subcommand\f[].
Commands take a list of hosts to be included in the certificate.
.TP
-.B request hosts
+.B \f[C]request\ hosts\f[]
Create a certificate request (CSR) file for submission to a certificate
authority.
Multiple hosts can be given, sub\-domains are automatically included.
.RS
.RE
.TP
-.B generate hosts
+.B \f[C]generate\ hosts\f[]
Generate a self\-signed certificate.
.RS
.RE
.TP
-.B key host [size]
+.B \f[C]key\ host\ [size]\f[]
Generate a private key of \[aq]size\[aq] bits (defaults to 2048).
Invoked automatically by \[aq]request\[aq] and \[aq]generate\[aq] if
needed.
.RS
.RE
.TP
-.B config hosts
+.B \f[C]config\ hosts\f[]
Produce a config file for the list of hosts.
Invoked automatically by \[aq]request\[aq] and \[aq]generate\[aq] if
needed.
.RS
.RE
.TP
-.B import hosts paths
+.B \f[C]import\ hosts\ paths\f[]
Copy certificates for hosts into the certificate path and reload
prosody.
.RS
@@ -129,13 +129,13 @@ prosody.
prosodyctl can also show some information about the environment,
dependencies and such to aid in debugging.
.TP
-.B about
+.B \f[C]about\f[]
Shows environment, various paths used by Prosody and installed
dependencies.
.RS
.RE
.TP
-.B check [what]
+.B \f[C]check\ [what]\f[]
Performs various sanity checks on the configuration, DNS setup and
configured TLS certificates.
\f[C]what\f[] can be one of \f[C]config\f[], \f[C]dns\f[] and
diff --git a/man/prosodyctl.markdown b/man/prosodyctl.markdown
index 9cc15985..121547fd 100644
--- a/man/prosodyctl.markdown
+++ b/man/prosodyctl.markdown
@@ -88,23 +88,23 @@ private keys for use with Prosody. Commands are of the form
`prosodyctl cert subcommand`. Commands take a list of hosts to be
included in the certificate.
-request hosts
+`request hosts`
: Create a certificate request (CSR) file for submission to a
certificate authority. Multiple hosts can be given, sub-domains are
automatically included.
-generate hosts
+`generate hosts`
: Generate a self-signed certificate.
-key host \[size\]
+`key host [size]`
: Generate a private key of 'size' bits (defaults to 2048). Invoked
automatically by 'request' and 'generate' if needed.
-config hosts
+`config hosts`
: Produce a config file for the list of hosts. Invoked automatically
by 'request' and 'generate' if needed.
-import hosts paths
+`import hosts paths`
: Copy certificates for hosts into the certificate path and reload
prosody.
@@ -114,11 +114,11 @@ Debugging
prosodyctl can also show some information about the environment,
dependencies and such to aid in debugging.
-about
+`about`
: Shows environment, various paths used by Prosody and installed
dependencies.
-check \[what\]
+`check [what]`
: Performs various sanity checks on the configuration, DNS setup and
configured TLS certificates. `what` can be one of `config`, `dns`
and `certs` to run only that check.
diff --git a/net/http/server.lua b/net/http/server.lua
index 8aa28f5c..877c7f17 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -229,7 +229,7 @@ function handle_request(conn, request, finish_cb)
if err then
response.status_code = err_code;
- response:send(events.fire_event("http-error", { code = err_code, message = err }));
+ response:send(events.fire_event("http-error", { code = err_code, message = err, response = response }));
return;
end
@@ -244,7 +244,8 @@ function handle_request(conn, request, finish_cb)
if result_type == "number" then
response.status_code = result;
if result >= 400 then
- body = events.fire_event("http-error", { code = result });
+ payload.code = result;
+ body = events.fire_event("http-error", payload);
end
elseif result_type == "string" then
body = result;
@@ -266,7 +267,8 @@ function handle_request(conn, request, finish_cb)
-- if handler not called, return 404
response.status_code = 404;
- response:send(events.fire_event("http-error", { code = 404 }));
+ payload.code = 404;
+ response:send(events.fire_event("http-error", payload));
end
local function prepare_header(response)
local status_line = "HTTP/"..response.request.httpversion.." "..(response.status or codes[response.status_code]);
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