Changeset

8366:272ff3ab25f3

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Sun, 29 Oct 2017 02:05:19 +0200
parents 8352:6ff50541d2a6 (current diff) 8365:8e079677d724 (diff)
children 8367:60eb22fd21b8
files
diffstat 8 files changed, 64 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/core/loggingmanager.lua	Wed Oct 25 21:59:33 2017 +0200
+++ b/core/loggingmanager.lua	Sun Oct 29 02:05:19 2017 +0200
@@ -178,7 +178,7 @@
 
 	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 .. " ";
--- a/core/rostermanager.lua	Wed Oct 25 21:59:33 2017 +0200
+++ b/core/rostermanager.lua	Sun Oct 29 02:05:19 2017 +0200
@@ -104,9 +104,9 @@
 	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 @@
 	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 });
--- a/man/prosodyctl.man	Wed Oct 25 21:59:33 2017 +0200
+++ b/man/prosodyctl.man	Sun Oct 29 02:05:19 2017 +0200
@@ -93,33 +93,33 @@
 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 @@
 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
--- a/man/prosodyctl.markdown	Wed Oct 25 21:59:33 2017 +0200
+++ b/man/prosodyctl.markdown	Sun Oct 29 02:05:19 2017 +0200
@@ -88,23 +88,23 @@
 `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 @@
 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.
--- a/net/http/server.lua	Wed Oct 25 21:59:33 2017 +0200
+++ b/net/http/server.lua	Sun Oct 29 02:05:19 2017 +0200
@@ -229,7 +229,7 @@
 
 	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 @@
 			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 @@
 
 	-- 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]);
--- a/plugins/mod_carbons.lua	Wed Oct 25 21:59:33 2017 +0200
+++ b/plugins/mod_carbons.lua	Sun Oct 29 02:05:19 2017 +0200
@@ -76,6 +76,9 @@
 
 	-- 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 })
--- a/plugins/mod_http_errors.lua	Wed Oct 25 21:59:33 2017 +0200
+++ b/plugins/mod_http_errors.lua	Sun Oct 29 02:05:19 2017 +0200
@@ -2,6 +2,8 @@
 
 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 @@
 <!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);
--- a/plugins/mod_mam/mamprefs.lib.lua	Wed Oct 25 21:59:33 2017 +0200
+++ b/plugins/mod_mam/mamprefs.lib.lua	Sun Oct 29 02:05:19 2017 +0200
@@ -33,9 +33,11 @@
 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