Mercurial > prosody-hg
comparison plugins/mod_proxy65.lua @ 4376:99277a1abe58
mod_proxy65: Apply stringprep to activation target JID.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sat, 03 Sep 2011 01:07:35 +0500 |
| parents | 81f5e83211dd |
| children | aa2e79f20962 |
comparison
equal
deleted
inserted
replaced
| 4375:81f5e83211dd | 4376:99277a1abe58 |
|---|---|
| 11 ]]-- | 11 ]]-- |
| 12 | 12 |
| 13 | 13 |
| 14 local module = module; | 14 local module = module; |
| 15 local tostring = tostring; | 15 local tostring = tostring; |
| 16 local jid_split, jid_join, jid_compare = require "util.jid".split, require "util.jid".join, require "util.jid".compare; | 16 local jid_compare, jid_prep = require "util.jid".compare, require "util.jid".prep; |
| 17 local st = require "util.stanza"; | 17 local st = require "util.stanza"; |
| 18 local connlisteners = require "net.connlisteners"; | 18 local connlisteners = require "net.connlisteners"; |
| 19 local sha1 = require "util.hashes".sha1; | 19 local sha1 = require "util.hashes".sha1; |
| 20 local server = require "net.server"; | 20 local server = require "net.server"; |
| 21 | 21 |
| 163 | 163 |
| 164 local query = stanza.tags[1]; | 164 local query = stanza.tags[1]; |
| 165 local sid = query.attr.sid; | 165 local sid = query.attr.sid; |
| 166 local from = stanza.attr.from; | 166 local from = stanza.attr.from; |
| 167 local to = query:get_child_text("activate"); | 167 local to = query:get_child_text("activate"); |
| 168 local prepped_to = jid_prep(to); | |
| 168 | 169 |
| 169 module:log("debug", "received activation request from %s", stanza.attr.from); | 170 module:log("debug", "received activation request from %s", stanza.attr.from); |
| 170 if to and sid then | 171 if prepped_to and sid then |
| 171 local sha = sha1(sid .. from .. to, true); | 172 local sha = sha1(sid .. from .. prepped_to, true); |
| 172 if transfers[sha] == nil then | 173 if transfers[sha] == nil then |
| 173 module:log("error", "transfers[sha]: nil"); | 174 module:log("error", "transfers[sha]: nil"); |
| 174 origin.send(st.error_reply(stanza, "modify", "item-not-found")); | 175 origin.send(st.error_reply(stanza, "modify", "item-not-found")); |
| 175 elseif(transfers[sha] ~= nil and transfers[sha].initiator ~= nil and transfers[sha].target ~= nil) then | 176 elseif(transfers[sha] ~= nil and transfers[sha].initiator ~= nil and transfers[sha].target ~= nil) then |
| 176 transfers[sha].activated = true; | 177 transfers[sha].activated = true; |
| 185 elseif transfers[sha].target then | 186 elseif transfers[sha].target then |
| 186 message = "The sender (you) is not connected to the proxy"; | 187 message = "The sender (you) is not connected to the proxy"; |
| 187 end | 188 end |
| 188 origin.send(st.error_reply(stanza, "cancel", "not-allowed", message)); | 189 origin.send(st.error_reply(stanza, "cancel", "not-allowed", message)); |
| 189 end | 190 end |
| 191 elseif to and sid then | |
| 192 origin.send(st.error_reply(stanza, "modify", "jid-malformed")); | |
| 190 else | 193 else |
| 191 module:log("error", "activation failed: sid: %s, initiator: %s, target: %s", tostring(sid), tostring(from), tostring(to)); | 194 module:log("error", "activation failed: sid: %s, initiator: %s, target: %s", tostring(sid), tostring(from), tostring(to)); |
| 192 origin.send(st.error_reply(stanza, "modify", "bad-request")); | 195 origin.send(st.error_reply(stanza, "modify", "bad-request")); |
| 193 end | 196 end |
| 194 return true; | 197 return true; |
