# HG changeset patch # User Kim Alvefur # Date 1365457086 -7200 # Node ID 020b5944a9738c43ff359d26f02e25737d50e231 # Parent aeb11522a44f405b3c0009b61fbea95bdbe579f7 mod_seclabels: Allow stanzas or XML strings as labels in the config diff -r aeb11522a44f -r 020b5944a973 mod_seclabels/mod_seclabels.lua --- a/mod_seclabels/mod_seclabels.lua Mon Apr 08 22:26:52 2013 +0200 +++ b/mod_seclabels/mod_seclabels.lua Mon Apr 08 23:38:06 2013 +0200 @@ -1,4 +1,5 @@ local st = require "util.stanza"; +local xml = require "util.xml"; local xmlns_label = "urn:xmpp:sec-label:0"; local xmlns_label_catalog = "urn:xmpp:sec-label:catalog:2"; @@ -61,8 +62,15 @@ bgcolor = item.bgcolor, }):text(item.display or name):up(); end - if type(item.label) == "string" then - catalog:tag("label"):text(item.label):up(); + if item.label == true then + catalog:tag("label"):text(name):up(); + elseif type(item.label) == "string" then + -- TODO Do we need anything other than XML parsing? + if item.label:sub(1,1) == "<" then + catalog:tag("label"):add_child(xml.parse(item.label)):up(); + else + catalog:tag("label"):text(item.label):up(); + end elseif type(item.label) == "table" then catalog:tag("label"):add_child(item.label):up(); end