aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-01-15 04:36:35 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-01-15 04:36:35 +0500
commit60886540232400adc81e712f5026e0d6f2cfbf07 (patch)
tree5438410f65220476d0abfcc0778d512818766972 /core
parent7a3cc5323272cfd22a092de5f5217379a8887050 (diff)
downloadprosody-60886540232400adc81e712f5026e0d6f2cfbf07.tar.gz
prosody-60886540232400adc81e712f5026e0d6f2cfbf07.zip
Stringprep!
Diffstat (limited to 'core')
-rw-r--r--core/stanza_router.lua28
1 files changed, 23 insertions, 5 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index 52028653..4704625b 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -47,9 +47,10 @@ local tonumber = tonumber;
local s_find = string.find;
local jid_split = require "util.jid".split;
+local jid_prepped_split = require "util.jid".prepped_split;
local print = print;
local function checked_error_reply(origin, stanza)
- if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server" or not stanza.attr.xmlns) and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
+ if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
end
end
@@ -78,11 +79,28 @@ function core_process_stanza(origin, stanza)
stanza.attr.from = origin.full_jid;
end
local to, xmlns = stanza.attr.to, stanza.attr.xmlns;
- local node, host, resource = jid_split(to);
- local to_bare = node and (node.."@"..host) or host; -- bare JID
local from = stanza.attr.from;
- 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
+ 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");
+ end
+ from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID
+ if from_resource then from = from_bare.."/"..from_resource; else from = from_bare; end
+ stanza.attr.from = from;
+ end
--[[if to and not(hosts[to]) and not(hosts[to_bare]) and (hosts[host] and hosts[host].type ~= "local") then -- not for us?
log("warn", "stanza recieved for a non-local server");