Comparison

mod_http_upload/mod_http_upload.lua @ 1966:3b748666ff97

mod_http_upload: URL-encode filename in case it contains characters that need escaping (thanks Thilo)
author Kim Alvefur <zash@zash.se>
date Fri, 11 Dec 2015 18:00:43 +0100
parent 1942:ff95d983940c
child 1967:2ce2b194d501
comparison
equal deleted inserted replaced
1965:3d8e2480fae0 1966:3b748666ff97
9 9
10 -- imports 10 -- imports
11 local st = require"util.stanza"; 11 local st = require"util.stanza";
12 local lfs = require"lfs"; 12 local lfs = require"lfs";
13 local uuid = require"util.uuid".generate; 13 local uuid = require"util.uuid".generate;
14 local urlencode = require"util.http".urlencode;
14 local t_concat = table.concat; 15 local t_concat = table.concat;
15 local t_insert = table.insert; 16 local t_insert = table.insert;
16 local s_upper = string.upper; 17 local s_upper = string.upper;
17 18
18 local function join_path(a, b) 19 local function join_path(a, b)
64 end 65 end
65 local reply = st.reply(stanza); 66 local reply = st.reply(stanza);
66 reply:tag("slot", { xmlns = xmlns_http_upload }); 67 reply:tag("slot", { xmlns = xmlns_http_upload });
67 local random = uuid(); 68 local random = uuid();
68 pending_slots[random.."/"..filename] = origin.full_jid; 69 pending_slots[random.."/"..filename] = origin.full_jid;
69 local url = module:http_url() .. "/" .. random .. "/" .. filename; 70 local url = module:http_url() .. "/" .. random .. "/" .. urlencode(filename);
70 reply:tag("get"):text(url):up(); 71 reply:tag("get"):text(url):up();
71 reply:tag("put"):text(url):up(); 72 reply:tag("put"):text(url):up();
72 origin.send(reply); 73 origin.send(reply);
73 return true; 74 return true;
74 end); 75 end);