changeset 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
parents e9de45beaf5e
children b07193056935
files mod_muc_log/mod_muc_log.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_log/mod_muc_log.lua	Mon Oct 19 22:15:57 2009 +0200
+++ b/mod_muc_log/mod_muc_log.lua	Mon Oct 19 22:43:30 2009 +0200
@@ -26,6 +26,7 @@
 ]]--
 local html = {};
 html.doc = [[<html>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
 <head>
 	<title>muc_log</title>
 </head>
@@ -157,8 +158,11 @@
 end
 
 local function htmlEscape(t)
+	t = t:gsub("<", "&lt;");
+	t = t:gsub(">", "&gt;");
+	t = t:gsub("(http://[%a%d@%.:/&%?=%-_#]+)", [[<a href="%1">%1</a>]]);
 	t = t:gsub("\n", "<br />");
-	-- TODO link text into klickable link and such stuff
+	-- TODO do any html escaping stuff ... 
 	return t;
 end