--- a/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua Mon Jan 04 14:20:48 2010 +0000
+++ b/mod_muc_log_http/muc_log_http/mod_muc_log_http.lua Thu Jan 14 12:54:44 2010 +0100
@@ -8,6 +8,7 @@
local tabSort = table.sort;
local tonumber = _G.tonumber;
local tostring = _G.tostring;
+local strchar = string.char;
local strformat = string.format;
local splitJid = require "util.jid".split;
local config_get = require "core.configmanager".get;
@@ -71,10 +72,20 @@
end
end
+function urlunescape (escapedUrl)
+ escapedUrl = escapedUrl:gsub("+", " ")
+ escapedUrl = escapedUrl:gsub("%%(%x%x)", function(h) return strchar(tonumber(h,16)) end)
+ escapedUrl = escapedUrl:gsub("\r\n", "\n")
+ return escapedUrl
+end
+
local function htmlEscape(t)
t = t:gsub("<", "<");
t = t:gsub(">", ">");
- t = t:gsub("(http://[%a%d@%.:/&%?=%-_#]+)", [[<a href="%1">%1</a>]]);
+ t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%]+)", function(h)
+ h = urlunescape(h)
+ return "<a href='" .. h .. "'>" .. h .. "</a>";
+ end);
t = t:gsub("\n", "<br />");
return t;
end