# HG changeset patch # User Stephen Paul Weber # Date 1676918506 18000 # Node ID 1682166171fffc9988b27b1a1b61a492e94deefc # Parent 4d6af8950016ab286bc5287acccf4b37cd76fb4d Strip images from XHTML-IM as well diff -r 4d6af8950016 -r 1682166171ff mod_muc_restrict_media/mod_muc_restrict_media.lua --- a/mod_muc_restrict_media/mod_muc_restrict_media.lua Sun Feb 19 18:17:37 2023 +0100 +++ b/mod_muc_restrict_media/mod_muc_restrict_media.lua Mon Feb 20 13:41:46 2023 -0500 @@ -48,6 +48,19 @@ formdata["{xmpp:prosody.im}muc#roomconfig_unaffiliated_media"] = allow_unaffiliated_media; end); +local function strip_xhtml_img(tag) + if tag.attr.xmlns == "http://www.w3.org/1999/xhtml" and tag.name == "img" then + tag.name = "i"; + tag:text(tag.attr.alt or ""); + tag.attr = { xmlns = tag.attr.xmlns, title = tag.attr.title }; + tag:maptags(strip_xhtml_img); + else + tag:maptags(strip_xhtml_img); + end + + return tag; +end + local function filter_media_tags(tag) local xmlns = tag.attr.xmlns; if xmlns == "jabber:x:oob" then @@ -56,6 +69,8 @@ if tag:get_child("media-sharing", "urn:xmpp:sims:1") then return nil; end + elseif xmlns == "http://jabber.org/protocol/xhtml-im" then + return strip_xhtml_img(tag); end return tag; end