mod_http_upload/mod_http_upload.lua
changeset 1852 e5243fa16210
parent 1821 1971ff719e72
child 1853 5244c9b0b297
equal deleted inserted replaced
1851:cd98a1103ecf 1852: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);