comparison mod_muc_log_http/muc_log_http/mod_muc_log_http.lua @ 117:ecf05eb2d833

mod_muc_log_http: support even more evil url stuff, don't forget %-signs
author Thilo Cestonaro <thilo@cestona.ro>
date Thu, 14 Jan 2010 15:40:10 +0100
parents f68a781efe81
children 7eadcf0a0190
comparison
equal deleted inserted replaced
116:f68a781efe81 117:ecf05eb2d833
66 return false; 66 return false;
67 end 67 end
68 68
69 function createDoc(body) 69 function createDoc(body)
70 if body then 70 if body then
71 body = body:gsub("%%", "%%%%");
71 return html.doc:gsub("###BODY_STUFF###", body); 72 return html.doc:gsub("###BODY_STUFF###", body);
72 end 73 end
73 end 74 end
74 75
75 function urlunescape (escapedUrl) 76 function urlunescape (escapedUrl)
80 end 81 end
81 82
82 local function htmlEscape(t) 83 local function htmlEscape(t)
83 t = t:gsub("<", "&lt;"); 84 t = t:gsub("<", "&lt;");
84 t = t:gsub(">", "&gt;"); 85 t = t:gsub(">", "&gt;");
85 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%]+)", function(h) 86 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%~]+)", function(h)
86 h = urlunescape(h) 87 h = urlunescape(h)
87 return "<a href='" .. h .. "'>" .. h .. "</a>"; 88 return "<a href='" .. h .. "'>" .. h .. "</a>";
88 end); 89 end);
89 t = t:gsub("\n", "<br />"); 90 t = t:gsub("\n", "<br />");
91 t = t:gsub("%%", "%%%%");
90 return t; 92 return t;
91 end 93 end
92 94
93 function splitUrl(url) 95 function splitUrl(url)
94 local tmp = url:sub(string.len("/muc_log/") + 1); 96 local tmp = url:sub(string.len("/muc_log/") + 1);
581 nextDay = html.day.dayLink:gsub("###DAY###", nextDay):gsub("###TEXT###", "next day &gt;&gt;") 583 nextDay = html.day.dayLink:gsub("###DAY###", nextDay):gsub("###TEXT###", "next day &gt;&gt;")
582 end 584 end
583 if previousDay then 585 if previousDay then
584 previousDay = html.day.dayLink:gsub("###DAY###", previousDay):gsub("###TEXT###", "&lt;&lt; previous day"); 586 previousDay = html.day.dayLink:gsub("###DAY###", previousDay):gsub("###TEXT###", "&lt;&lt; previous day");
585 end 587 end
586 tmp = html.day.body:gsub("###DAY_STUFF###", ret):gsub("###JID###", bareRoomJid); 588 tmp = html.day.body:gsub("###DAY_STUFF###", ret:gsub("%%", "%%%%")):gsub("###JID###", bareRoomJid);
587 tmp = tmp:gsub("###YEAR###", year):gsub("###MONTH###", month):gsub("###DAY###", day); 589 tmp = tmp:gsub("###YEAR###", year):gsub("###MONTH###", month):gsub("###DAY###", day);
588 tmp = tmp:gsub("###TITLE_STUFF###", html.day.title:gsub("###TITLE###", roomSubject)); 590 tmp = tmp:gsub("###TITLE_STUFF###", html.day.title:gsub("###TITLE###", roomSubject));
589 tmp = tmp:gsub("###STATUS_CHECKED###", config.showStatus and "checked='checked'" or ""); 591 tmp = tmp:gsub("###STATUS_CHECKED###", config.showStatus and "checked='checked'" or "");
590 tmp = tmp:gsub("###JOIN_CHECKED###", config.showJoin and "checked='checked'" or ""); 592 tmp = tmp:gsub("###JOIN_CHECKED###", config.showJoin and "checked='checked'" or "");
591 tmp = tmp:gsub("###NEXT_LINK###", nextDay or ""); 593 tmp = tmp:gsub("###NEXT_LINK###", nextDay or "");