Mercurial > prosody-modules
comparison mod_muc_log_http/muc_log_http/mod_muc_log_http.lua @ 116:f68a781efe81
mod_muc_log_http: support escaped urls
author | Thilo Cestonaro <thilo@cestona.ro> |
---|---|
date | Thu, 14 Jan 2010 12:54:44 +0100 |
parents | 5e657a305c88 |
children | ecf05eb2d833 |
comparison
equal
deleted
inserted
replaced
115:5e657a305c88 | 116:f68a781efe81 |
---|---|
6 | 6 |
7 local prosody = prosody; | 7 local prosody = prosody; |
8 local tabSort = table.sort; | 8 local tabSort = table.sort; |
9 local tonumber = _G.tonumber; | 9 local tonumber = _G.tonumber; |
10 local tostring = _G.tostring; | 10 local tostring = _G.tostring; |
11 local strchar = string.char; | |
11 local strformat = string.format; | 12 local strformat = string.format; |
12 local splitJid = require "util.jid".split; | 13 local splitJid = require "util.jid".split; |
13 local config_get = require "core.configmanager".get; | 14 local config_get = require "core.configmanager".get; |
14 local httpserver = require "net.httpserver"; | 15 local httpserver = require "net.httpserver"; |
15 local datamanager = require "util.datamanager"; | 16 local datamanager = require "util.datamanager"; |
69 if body then | 70 if body then |
70 return html.doc:gsub("###BODY_STUFF###", body); | 71 return html.doc:gsub("###BODY_STUFF###", body); |
71 end | 72 end |
72 end | 73 end |
73 | 74 |
75 function urlunescape (escapedUrl) | |
76 escapedUrl = escapedUrl:gsub("+", " ") | |
77 escapedUrl = escapedUrl:gsub("%%(%x%x)", function(h) return strchar(tonumber(h,16)) end) | |
78 escapedUrl = escapedUrl:gsub("\r\n", "\n") | |
79 return escapedUrl | |
80 end | |
81 | |
74 local function htmlEscape(t) | 82 local function htmlEscape(t) |
75 t = t:gsub("<", "<"); | 83 t = t:gsub("<", "<"); |
76 t = t:gsub(">", ">"); | 84 t = t:gsub(">", ">"); |
77 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#]+)", [[<a href="%1">%1</a>]]); | 85 t = t:gsub("(http://[%a%d@%.:/&%?=%-_#%%]+)", function(h) |
86 h = urlunescape(h) | |
87 return "<a href='" .. h .. "'>" .. h .. "</a>"; | |
88 end); | |
78 t = t:gsub("\n", "<br />"); | 89 t = t:gsub("\n", "<br />"); |
79 return t; | 90 return t; |
80 end | 91 end |
81 | 92 |
82 function splitUrl(url) | 93 function splitUrl(url) |