Software / code / prosody-modules
Comparison
mod_http_upload/mod_http_upload.lua @ 1848:e5243fa16210
mod_http_upload: Cache first-level child <request> in local variable
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 14 Sep 2015 12:43:10 +0200 |
| parent | 1817:1971ff719e72 |
| child | 1849:5244c9b0b297 |
comparison
equal
deleted
inserted
replaced
| 1847:cd98a1103ecf | 1848:e5243fa16210 |
|---|---|
| 32 lfs.mkdir(storage_path); | 32 lfs.mkdir(storage_path); |
| 33 | 33 |
| 34 -- hooks | 34 -- hooks |
| 35 module:hook("iq/host/"..xmlns_http_upload..":request", function (event) | 35 module:hook("iq/host/"..xmlns_http_upload..":request", function (event) |
| 36 local stanza, origin = event.stanza, event.origin; | 36 local stanza, origin = event.stanza, event.origin; |
| 37 local request = stanza.tags[1]; | |
| 37 -- local clients only | 38 -- local clients only |
| 38 if origin.type ~= "c2s" then | 39 if origin.type ~= "c2s" then |
| 39 origin.send(st.error_reply(stanza, "cancel", "not-authorized")); | 40 origin.send(st.error_reply(stanza, "cancel", "not-authorized")); |
| 40 return true; | 41 return true; |
| 41 end | 42 end |
| 42 -- validate | 43 -- validate |
| 43 local filename = stanza.tags[1]:get_child_text("filename"); | 44 local filename = request:get_child_text("filename"); |
| 44 if not filename or filename:find("/") then | 45 if not filename or filename:find("/") then |
| 45 origin.send(st.error_reply(stanza, "modify", "bad-request")); | 46 origin.send(st.error_reply(stanza, "modify", "bad-request")); |
| 46 return true; | 47 return true; |
| 47 end | 48 end |
| 48 local reply = st.reply(stanza); | 49 local reply = st.reply(stanza); |