# HG changeset patch # User Marco Cirillo # Date 1336562722 0 # Node ID bda0593d3f73fe9d040975d3668b5d4cfaa7d691 # Parent 751510cd558d82eed7d78c28cfe4cf471d9d61c7 mod_dialback: add better safe then sorry nameprepping to the from attribute. diff -r 751510cd558d -r bda0593d3f73 plugins/mod_dialback.lua --- a/plugins/mod_dialback.lua Wed May 09 02:56:22 2012 +0000 +++ b/plugins/mod_dialback.lua Wed May 09 11:25:22 2012 +0000 @@ -15,6 +15,7 @@ local st = require "util.stanza"; local sha256_hash = require "util.hashes".sha256; +local nameprep = require "util.encodings".stringprep.nameprep; local xmlns_stream = "http://etherx.jabber.org/streams"; @@ -77,10 +78,15 @@ if not origin.from_host then -- Just used for friendlier logging - origin.from_host = attr.from; + origin.from_host = nameprep(attr.from); -- COMPAT: Fix ejabberd chopness by resetting the send function - origin.log("debug", "Remote server didn't specify a from attr, resetting session.send now that we know where to knock to."); - origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end + if not origin.from_host then + origin.log("debug", "We need to know where to connect but remote server blindly refuses to tell us and to comply to specs, closing connection."); + origin:close("invalid-from"); + else + origin.log("debug", "Remote server didn't specify a from attr, resetting session.send now that we know where to knock to."); + origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end + end end if not origin.to_host then -- Just used for friendlier logging