Comparison

util/stanza.lua @ 10444:4eab1f5a4f3b

util.stanza: Check that argument to error_reply is a stanza
author Kim Alvefur <zash@zash.se>
date Mon, 25 Nov 2019 20:52:01 +0100
parent 10443:f28718f46196
child 10445:f53c03ab4357
comparison
equal deleted inserted replaced
10443:f28718f46196 10444:4eab1f5a4f3b
446 }); 446 });
447 end 447 end
448 448
449 local xmpp_stanzas_attr = { xmlns = xmlns_stanzas }; 449 local xmpp_stanzas_attr = { xmlns = xmlns_stanzas };
450 local function error_reply(orig, error_type, condition, error_message) 450 local function error_reply(orig, error_type, condition, error_message)
451 if not is_stanza(orig) then
452 error("bad argument to error_reply: expected stanza, got "..type(orig));
453 end
451 local t = reply(orig); 454 local t = reply(orig);
452 t.attr.type = "error"; 455 t.attr.type = "error";
453 t:tag("error", {type = error_type}) --COMPAT: Some day xmlns:stanzas goes here 456 t:tag("error", {type = error_type}) --COMPAT: Some day xmlns:stanzas goes here
454 :tag(condition, xmpp_stanzas_attr):up(); 457 :tag(condition, xmpp_stanzas_attr):up();
455 if error_message then t:text_tag("text", error_message, xmpp_stanzas_attr); end 458 if error_message then t:text_tag("text", error_message, xmpp_stanzas_attr); end