Comparison

mod_muc_log/mod_muc_log.lua @ 57:cddcea7c091a

mod_muc_log: set content-type header; escape some html stuff in messages (>, <, \n, http://....)
author Thilo Cestonaro <thilo@cestona.ro>
date Mon, 19 Oct 2009 22:43:30 +0200
parent 56:e9de45beaf5e
child 59:50e3d5b87119
comparison
equal deleted inserted replaced
56:e9de45beaf5e 57:cddcea7c091a
24 --[[ 24 --[[
25 * Default templates for the html output. 25 * Default templates for the html output.
26 ]]-- 26 ]]--
27 local html = {}; 27 local html = {};
28 html.doc = [[<html> 28 html.doc = [[<html>
29 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
29 <head> 30 <head>
30 <title>muc_log</title> 31 <title>muc_log</title>
31 </head> 32 </head>
32 <style type="text/css"> 33 <style type="text/css">
33 <!-- 34 <!--
155 function createDoc(body) 156 function createDoc(body)
156 return html.doc:gsub("###BODY_STUFF###", body); 157 return html.doc:gsub("###BODY_STUFF###", body);
157 end 158 end
158 159
159 local function htmlEscape(t) 160 local function htmlEscape(t)
161 t = t:gsub("<", "&lt;");
162 t = t:gsub(">", "&gt;");
163 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#]+)", [[<a href="%1">%1</a>]]);
160 t = t:gsub("\n", "<br />"); 164 t = t:gsub("\n", "<br />");
161 -- TODO link text into klickable link and such stuff 165 -- TODO do any html escaping stuff ...
162 return t; 166 return t;
163 end 167 end
164 168
165 function splitQuery(query) 169 function splitQuery(query)
166 local ret = {}; 170 local ret = {};