Software /
code /
prosody
Comparison
core/stanza_router.lua @ 1270:0e700e2041ef
stanza_router: Don't reply with an error on invalid JIDs in error or result stanzas
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 01 Jun 2009 15:48:39 +0500 |
parent | 1269:b06d6674477b |
child | 1273:85353014ff34 |
comparison
equal
deleted
inserted
replaced
1269:b06d6674477b | 1270:0e700e2041ef |
---|---|
79 local to_bare, from_bare; | 79 local to_bare, from_bare; |
80 if to then | 80 if to then |
81 node, host, resource = jid_prepped_split(to); | 81 node, host, resource = jid_prepped_split(to); |
82 if not host then | 82 if not host then |
83 log("warn", "Received stanza with invalid destination JID: %s", to); | 83 log("warn", "Received stanza with invalid destination JID: %s", to); |
84 origin.send(st.error_reply(stanza, "modify", "jid-malformed", "The destination address is invalid: "..to)); | 84 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then |
85 origin.send(st.error_reply(stanza, "modify", "jid-malformed", "The destination address is invalid: "..to)); | |
86 end | |
85 return; | 87 return; |
86 end | 88 end |
87 to_bare = node and (node.."@"..host) or host; -- bare JID | 89 to_bare = node and (node.."@"..host) or host; -- bare JID |
88 if resource then to = to_bare.."/"..resource; else to = to_bare; end | 90 if resource then to = to_bare.."/"..resource; else to = to_bare; end |
89 stanza.attr.to = to; | 91 stanza.attr.to = to; |
91 if from then | 93 if from then |
92 -- We only stamp the 'from' on c2s stanzas, so we still need to check validity | 94 -- We only stamp the 'from' on c2s stanzas, so we still need to check validity |
93 from_node, from_host, from_resource = jid_prepped_split(from); | 95 from_node, from_host, from_resource = jid_prepped_split(from); |
94 if not from_host then | 96 if not from_host then |
95 log("warn", "Received stanza with invalid source JID: %s", from); | 97 log("warn", "Received stanza with invalid source JID: %s", from); |
96 origin.send(st.error_reply(stanza, "modify", "jid-malformed", "The source address is invalid: "..from)); | 98 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then |
99 origin.send(st.error_reply(stanza, "modify", "jid-malformed", "The source address is invalid: "..from)); | |
100 end | |
97 return; | 101 return; |
98 end | 102 end |
99 from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID | 103 from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID |
100 if from_resource then from = from_bare.."/"..from_resource; else from = from_bare; end | 104 if from_resource then from = from_bare.."/"..from_resource; else from = from_bare; end |
101 stanza.attr.from = from; | 105 stanza.attr.from = from; |