comparison util/error.lua @ 13078:6da83deb8d7f 0.12

util.error: Fix error on conversion of invalid error stanza, fix #1805 Error stanzas should have an <error> element, but if you pass a stanza without one to util.error.from_stanza() it triggers an attempt to index a nil value, which this patch avoids. In the conditional, it should be safe to assume error_tag is non-nil since condition can't have those values then.
author Kim Alvefur <zash@zash.se>
date Wed, 19 Apr 2023 11:32:53 +0200
parents 8143fd2f138b
children e7a5e5a0dc02
comparison
equal deleted inserted replaced
13077:de42a93a7c8d 13078:6da83deb8d7f
139 local function from_stanza(stanza, context, source) 139 local function from_stanza(stanza, context, source)
140 local error_type, condition, text, extra_tag = stanza:get_error(); 140 local error_type, condition, text, extra_tag = stanza:get_error();
141 local error_tag = stanza:get_child("error"); 141 local error_tag = stanza:get_child("error");
142 context = context or {}; 142 context = context or {};
143 context.stanza = stanza; 143 context.stanza = stanza;
144 context.by = error_tag.attr.by or stanza.attr.from; 144 context.by = error_tag and error_tag.attr.by or stanza.attr.from;
145 145
146 local uri; 146 local uri;
147 if condition == "gone" or condition == "redirect" then 147 if condition == "gone" or condition == "redirect" then
148 uri = error_tag:get_child_text(condition, "urn:ietf:params:xml:ns:xmpp-stanzas"); 148 uri = error_tag:get_child_text(condition, "urn:ietf:params:xml:ns:xmpp-stanzas");
149 end 149 end