# HG changeset patch # User Thilo Cestonaro # Date 1263470084 -3600 # Node ID f68a781efe81ade17c4d3f63bd8fed7f8dee2a11 # Parent 5e657a305c8878efac82a887cb49531c8cc07502 mod_muc_log_http: support escaped urls diff -r 5e657a305c88 -r f68a781efe81 mod_muc_log_http/muc_log_http/mod_muc_log_http.lua --- 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@%.:/&%?=%-_#]+)", [[%1]]); + t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%]+)", function(h) + h = urlunescape(h) + return "" .. h .. ""; + end); t = t:gsub("\n", "
"); return t; end