comparison mod_muc_log_http/muc_log_http/mod_muc_log_http.lua @ 344:2b0f2160fc61

mod_muc_log_http: Fix room name encoding/decoding (for UTF-8 room names)
author Joseph Wallace <JosephWallace@letu.edu>
date Sat, 05 Mar 2011 18:52:43 +0000
parents 845a59c99b4d
children 03e1dc036a28
comparison
equal deleted inserted replaced
343:845a59c99b4d 344:2b0f2160fc61
13 local strchar = string.char; 13 local strchar = string.char;
14 local strformat = string.format; 14 local strformat = string.format;
15 local splitJid = require "util.jid".split; 15 local splitJid = require "util.jid".split;
16 local config_get = require "core.configmanager".get; 16 local config_get = require "core.configmanager".get;
17 local httpserver = require "net.httpserver"; 17 local httpserver = require "net.httpserver";
18 local urlencode = require "net.http".urlencode;
19 local urldecode = require "net.http".urldecode;
18 local datamanager = require "util.datamanager"; 20 local datamanager = require "util.datamanager";
19 local data_load, data_getpath = datamanager.load, datamanager.getpath; 21 local data_load, data_getpath = datamanager.load, datamanager.getpath;
20 local datastore = "muc_log"; 22 local datastore = "muc_log";
21 local urlBase = "muc_log"; 23 local urlBase = "muc_log";
22 local muc_hosts = {}; 24 local muc_hosts = {};
286 local year = year; 288 local year = year;
287 if year > 2000 then 289 if year > 2000 then
288 year = year - 2000; 290 year = year - 2000;
289 end 291 end
290 local bareDay = str_format("%.02d%.02d%.02d", year, month, day); 292 local bareDay = str_format("%.02d%.02d%.02d", year, month, day);
293 room = urlencode(room);
291 local attributes, err = lfs.attributes(path.."/"..bareDay.."/"..room..".dat") 294 local attributes, err = lfs.attributes(path.."/"..bareDay.."/"..room..".dat")
292 if attributes ~= nil and attributes.mode == "file" then 295 if attributes ~= nil and attributes.mode == "file" then
293 local s = html.days.bit; 296 local s = html.days.bit;
294 s = s:gsub("###BARE_DAY###", webPath .. bareDay); 297 s = s:gsub("###BARE_DAY###", webPath .. bareDay);
295 s = s:gsub("###DAY###", day); 298 s = s:gsub("###DAY###", day);
691 end 694 end
692 end 695 end
693 696
694 function handle_request(method, body, request) 697 function handle_request(method, body, request)
695 local node, host, day = splitUrl(request.url.path); 698 local node, host, day = splitUrl(request.url.path);
696 699
700 node = urldecode(node);
701
697 if muc_hosts ~= nil and html.doc ~= nil then 702 if muc_hosts ~= nil and html.doc ~= nil then
698 if node ~= nil and host ~= nil then 703 if node ~= nil and host ~= nil then
699 local bare = node .. "@" .. host; 704 local bare = node .. "@" .. host;
700 if prosody.hosts[host] ~= nil and prosody.hosts[host].muc ~= nil then 705 if prosody.hosts[host] ~= nil and prosody.hosts[host].muc ~= nil then
701 if prosody.hosts[host].muc.rooms[bare] ~= nil then 706 if prosody.hosts[host].muc.rooms[bare] ~= nil then