Diff

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
line wrap: on
line diff
--- a/mod_http_upload/mod_http_upload.lua	Mon Sep 14 12:42:08 2015 +0200
+++ b/mod_http_upload/mod_http_upload.lua	Mon Sep 14 12:43:10 2015 +0200
@@ -34,13 +34,14 @@
 -- hooks
 module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
 	local stanza, origin = event.stanza, event.origin;
+	local request = stanza.tags[1];
 	-- local clients only
 	if origin.type ~= "c2s" then
 		origin.send(st.error_reply(stanza, "cancel", "not-authorized"));
 		return true;
 	end
 	-- validate
-	local filename = stanza.tags[1]:get_child_text("filename");
+	local filename = request:get_child_text("filename");
 	if not filename or filename:find("/") then
 		origin.send(st.error_reply(stanza, "modify", "bad-request"));
 		return true;