Software /
code /
prosody-modules
Comparison
mod_muc_restrict_media/mod_muc_restrict_media.lua @ 5171:1682166171ff
Strip images from XHTML-IM as well
author | Stephen Paul Weber <singpolyma@singpolyma.net> |
---|---|
date | Mon, 20 Feb 2023 13:41:46 -0500 |
parent | 4962:5a3031613dbc |
comparison
equal
deleted
inserted
replaced
5170:4d6af8950016 | 5171:1682166171ff |
---|---|
46 type = "boolean", | 46 type = "boolean", |
47 }); | 47 }); |
48 formdata["{xmpp:prosody.im}muc#roomconfig_unaffiliated_media"] = allow_unaffiliated_media; | 48 formdata["{xmpp:prosody.im}muc#roomconfig_unaffiliated_media"] = allow_unaffiliated_media; |
49 end); | 49 end); |
50 | 50 |
51 local function strip_xhtml_img(tag) | |
52 if tag.attr.xmlns == "http://www.w3.org/1999/xhtml" and tag.name == "img" then | |
53 tag.name = "i"; | |
54 tag:text(tag.attr.alt or "<image blocked>"); | |
55 tag.attr = { xmlns = tag.attr.xmlns, title = tag.attr.title }; | |
56 tag:maptags(strip_xhtml_img); | |
57 else | |
58 tag:maptags(strip_xhtml_img); | |
59 end | |
60 | |
61 return tag; | |
62 end | |
63 | |
51 local function filter_media_tags(tag) | 64 local function filter_media_tags(tag) |
52 local xmlns = tag.attr.xmlns; | 65 local xmlns = tag.attr.xmlns; |
53 if xmlns == "jabber:x:oob" then | 66 if xmlns == "jabber:x:oob" then |
54 return nil; | 67 return nil; |
55 elseif xmlns == "urn:xmpp:reference:0" then | 68 elseif xmlns == "urn:xmpp:reference:0" then |
56 if tag:get_child("media-sharing", "urn:xmpp:sims:1") then | 69 if tag:get_child("media-sharing", "urn:xmpp:sims:1") then |
57 return nil; | 70 return nil; |
58 end | 71 end |
72 elseif xmlns == "http://jabber.org/protocol/xhtml-im" then | |
73 return strip_xhtml_img(tag); | |
59 end | 74 end |
60 return tag; | 75 return tag; |
61 end | 76 end |
62 | 77 |
63 module:hook("muc-occupant-groupchat", function (event) | 78 module:hook("muc-occupant-groupchat", function (event) |