Changeset

981:020b5944a973

mod_seclabels: Allow stanzas or XML strings as labels in the config
author Kim Alvefur <zash@zash.se>
date Mon, 08 Apr 2013 23:38:06 +0200
parents 980:aeb11522a44f
children 982:ce8bb0386d08
files mod_seclabels/mod_seclabels.lua
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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