- local from_node, from_host, from_resource = jid_split(from);
- local from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID
-
- if origin.type == "s2sin" then
- if origin.from_host ~= from_host then -- remote server trying to impersonate some other server?
- log("warn", "Received a stanza claiming to be from %s, over a conn authed for %s!", from, origin.from_host);
- return; -- FIXME what should we do here? does this work with subdomains?
+ local node, host, resource;
+ local from_node, from_host, from_resource;
+ local to_bare, from_bare;
+ if to then
+ node, host, resource = jid_prepped_split(to);
+ if not host then
+ error("Invalid to JID");
+ end
+ to_bare = node and (node.."@"..host) or host; -- bare JID
+ if resource then to = to_bare.."/"..resource; else to = to_bare; end
+ stanza.attr.to = to;
+ end
+ if from then
+ from_node, from_host, from_resource = jid_prepped_split(from);
+ if not from_host then
+ error("Invalid from JID");