changeset 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 f37de7e2ad14
children b4f9518d5a00
files mod_muc_log_http/muc_log_http/mod_muc_log_http.lua
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua	Sat Mar 06 22:32:12 2010 +0500
+++ b/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua	Thu Mar 11 10:18:27 2010 +0100
@@ -81,14 +81,18 @@
 end
 
 local function htmlEscape(t)
-	t = t:gsub("<", "&lt;");
-	t = t:gsub(">", "&gt;");
-	t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%~]+)", function(h)
-		h = urlunescape(h)
-		return "<a href='" .. h .. "'>" .. h .. "</a>";
-	end);
-	t = t:gsub("\n", "<br />");
-	t = t:gsub("%%", "%%%%");
+	if t then
+		t = t:gsub("<", "&lt;");
+		t = t:gsub(">", "&gt;");
+		t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%~]+)", function(h)
+			h = urlunescape(h)
+			return "<a href='" .. h .. "'>" .. h .. "</a>";
+		end);
+		t = t:gsub("\n", "<br />");
+		t = t:gsub("%%", "%%%%");
+	else
+		t = "";
+	end
 	return t;
 end
 
@@ -375,7 +379,7 @@
 				alreadyJoined = true;
 			elseif tag.tag == "show" then
 				show = tag[1];
-			elseif tag.tag == "status" then
+			elseif tag.tag == "status" and tag[1] ~= nil then
 				status = tag[1];
 			end
 		end