# HG changeset patch
# User Thilo Cestonaro <thilo@cestona.ro>
# Date 1255985010 -7200
# Node ID cddcea7c091a2dbdb40699dbd9812d1172275adf
# Parent  e9de45beaf5e8ffac360c4a7555b602db4b15d75
mod_muc_log: set content-type header; escape some html stuff in messages (>, <, \n, http://....)

diff -r e9de45beaf5e -r cddcea7c091a mod_muc_log/mod_muc_log.lua
--- 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