comparison mod_muc_log_http/muc_log_http/mod_muc_log_http.lua @ 143:445efff314c4

mod_muc_log_http: handle empty status message tags; handle a nil-parameter in htmlEscape
author Thilo Cestonaro <thilo@cestona.ro>
date Thu, 11 Mar 2010 10:18:27 +0100
parents 7a2d33e8ad1f
children 2620bc59cca3
comparison
equal deleted inserted replaced
142:f37de7e2ad14 143:445efff314c4
79 escapedUrl = escapedUrl:gsub("\r\n", "\n") 79 escapedUrl = escapedUrl:gsub("\r\n", "\n")
80 return escapedUrl 80 return escapedUrl
81 end 81 end
82 82
83 local function htmlEscape(t) 83 local function htmlEscape(t)
84 t = t:gsub("<", "&lt;"); 84 if t then
85 t = t:gsub(">", "&gt;"); 85 t = t:gsub("<", "&lt;");
86 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%~]+)", function(h) 86 t = t:gsub(">", "&gt;");
87 h = urlunescape(h) 87 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%~]+)", function(h)
88 return "<a href='" .. h .. "'>" .. h .. "</a>"; 88 h = urlunescape(h)
89 end); 89 return "<a href='" .. h .. "'>" .. h .. "</a>";
90 t = t:gsub("\n", "<br />"); 90 end);
91 t = t:gsub("%%", "%%%%"); 91 t = t:gsub("\n", "<br />");
92 t = t:gsub("%%", "%%%%");
93 else
94 t = "";
95 end
92 return t; 96 return t;
93 end 97 end
94 98
95 function splitUrl(url) 99 function splitUrl(url)
96 local tmp = url:sub(string.len("/muc_log/") + 1); 100 local tmp = url:sub(string.len("/muc_log/") + 1);
373 for _, tag in ipairs(stanza) do 377 for _, tag in ipairs(stanza) do
374 if tag.tag == "alreadyJoined" then 378 if tag.tag == "alreadyJoined" then
375 alreadyJoined = true; 379 alreadyJoined = true;
376 elseif tag.tag == "show" then 380 elseif tag.tag == "show" then
377 show = tag[1]; 381 show = tag[1];
378 elseif tag.tag == "status" then 382 elseif tag.tag == "status" and tag[1] ~= nil then
379 status = tag[1]; 383 status = tag[1];
380 end 384 end
381 end 385 end
382 if alreadyJoined == true then 386 if alreadyJoined == true then
383 if show == nil then 387 if show == nil then