comparison mod_seclabels/mod_seclabels.lua @ 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 5276e1fc26b6
children 2df312eb816d
comparison
equal deleted inserted replaced
980:aeb11522a44f 981:020b5944a973
1 local st = require "util.stanza"; 1 local st = require "util.stanza";
2 local xml = require "util.xml";
2 3
3 local xmlns_label = "urn:xmpp:sec-label:0"; 4 local xmlns_label = "urn:xmpp:sec-label:0";
4 local xmlns_label_catalog = "urn:xmpp:sec-label:catalog:2"; 5 local xmlns_label_catalog = "urn:xmpp:sec-label:catalog:2";
5 local xmlns_label_catalog_old = "urn:xmpp:sec-label:catalog:0"; -- COMPAT 6 local xmlns_label_catalog_old = "urn:xmpp:sec-label:catalog:0"; -- COMPAT
6 7
59 catalog:tag("displaymarking", { 60 catalog:tag("displaymarking", {
60 fgcolor = item.color, 61 fgcolor = item.color,
61 bgcolor = item.bgcolor, 62 bgcolor = item.bgcolor,
62 }):text(item.display or name):up(); 63 }):text(item.display or name):up();
63 end 64 end
64 if type(item.label) == "string" then 65 if item.label == true then
65 catalog:tag("label"):text(item.label):up(); 66 catalog:tag("label"):text(name):up();
67 elseif type(item.label) == "string" then
68 -- TODO Do we need anything other than XML parsing?
69 if item.label:sub(1,1) == "<" then
70 catalog:tag("label"):add_child(xml.parse(item.label)):up();
71 else
72 catalog:tag("label"):text(item.label):up();
73 end
66 elseif type(item.label) == "table" then 74 elseif type(item.label) == "table" then
67 catalog:tag("label"):add_child(item.label):up(); 75 catalog:tag("label"):add_child(item.label):up();
68 end 76 end
69 catalog:up(); 77 catalog:up();
70 if catalog_request.attr.xmlns == xmlns_label_catalog then 78 if catalog_request.attr.xmlns == xmlns_label_catalog then