Comparison

mod_invite/mod_invite.lua @ 2238:dc4e77824318

mod_invite: Use XML/HTML entity escaping from util.stanza
author Kim Alvefur <zash@zash.se>
date Fri, 08 Jul 2016 23:56:42 +0200
parent 2058:4b3037c7af62
child 2239:df696c8d5282
comparison
equal deleted inserted replaced
2237:7c90e8a67a4f 2238:dc4e77824318
4 local jid_join = require "util.jid".join; 4 local jid_join = require "util.jid".join;
5 local http_formdecode = require "net.http".formdecode; 5 local http_formdecode = require "net.http".formdecode;
6 local http_urlencode = require "net.http".urlencode; 6 local http_urlencode = require "net.http".urlencode;
7 local usermanager = require "core.usermanager"; 7 local usermanager = require "core.usermanager";
8 local rostermanager = require "core.rostermanager"; 8 local rostermanager = require "core.rostermanager";
9 local tohtml = require "util.stanza".xml_escape
9 local nodeprep = require "util.encodings".stringprep.nodeprep; 10 local nodeprep = require "util.encodings".stringprep.nodeprep;
10 local tostring = tostring; 11 local tostring = tostring;
11 12
12 local invite_storage = module:open_store(); 13 local invite_storage = module:open_store();
13 local inviter_storage = module:open_store("inviter"); 14 local inviter_storage = module:open_store("inviter");
14 15
15 local serve = module:depends"http_files".serve; 16 local serve = module:depends"http_files".serve;
16 17
17 module:depends"http"; 18 module:depends"http";
18
19 local entities = {
20 ["<"] = "&lt;", [">"] = "&gt;", ["&"] = "&amp;",
21 ["'"] = "&apos;", ["\""] = "&quot;", ["\n"] = "<br/>",
22 };
23
24 local function tohtml(plain)
25 return (plain:gsub("[<>&'\"\n]", entities));
26 end
27 19
28 local function apply_template(template, args) 20 local function apply_template(template, args)
29 return 21 return
30 template:gsub("{{([^}]*)}}", function (k) 22 template:gsub("{{([^}]*)}}", function (k)
31 if args[k] then 23 if args[k] then