# HG changeset patch # User Kim Alvefur # Date 1579909569 -3600 # Node ID 8bdb1729529b20179ee8f7e6d00a7e10d061a777 # Parent 0e1e900577c42afbec921bc433a21a2018bb293b mod_rest: Make XHTML-IM mapping more convenient Avoid burdening web developers with XML namespace attribute Might be a bit fragile Note that the element must be included diff -r 0e1e900577c4 -r 8bdb1729529b mod_rest/jsonmap.lib.lua --- a/mod_rest/jsonmap.lib.lua Sat Jan 25 00:43:28 2020 +0100 +++ b/mod_rest/jsonmap.lib.lua Sat Jan 25 00:46:09 2020 +0100 @@ -25,15 +25,14 @@ join = {"bool_tag", "http://jabber.org/protocol/muc", "x"}, -- XEP-0071 - -- FIXME xmlns is awkward html = { "func", "http://jabber.org/protocol/xhtml-im", "html", function (s) --> json string - return tostring(s:get_child("body", "http://www.w3.org/1999/xhtml")); + return (tostring(s:get_child("body", "http://www.w3.org/1999/xhtml")):gsub(" xmlns='[^']*'","", 1)); end; function (s) --> xml if type(s) == "string" then - return xml.parse([[]]..s..[[]]); + return assert(xml.parse([[]]..s..[[]])); end end; };