# HG changeset patch # User Kim Alvefur # Date 1605454188 -3600 # Node ID 8b489203e4d3361a4e7af86c9d2b3480b18ac0ec # Parent 64aa1d9d70ac49b6ace6ef509d2dcedb3240aba8 mod_rest: Ensure no attempt is made to reply to an error stanza Previously it was possible to return an error reply from a callback. diff -r 64aa1d9d70ac -r 8b489203e4d3 mod_rest/mod_rest.lua --- a/mod_rest/mod_rest.lua Sun Nov 15 16:25:49 2020 +0100 +++ b/mod_rest/mod_rest.lua Sun Nov 15 16:29:48 2020 +0100 @@ -297,14 +297,11 @@ local function handle_stanza(event) local stanza, origin = event.stanza, event.origin; - local reply_needed = stanza.name == "iq"; + local reply_allowed = stanza.attr.type ~= "error"; + local reply_needed = reply_allowed and stanza.name == "iq"; local receipt; - if stanza.attr.type == "error" then - reply_needed = false; - end - - if stanza.name == "message" and stanza.attr.id and stanza:get_child("urn:xmpp:receipts", "request") then + if reply_allowed and stanza.name == "message" and stanza.attr.id and stanza:get_child("urn:xmpp:receipts", "request") then reply_needed = true; receipt = st.stanza("received", { xmlns = "urn:xmpp:receipts", id = stanza.id }); end @@ -327,7 +324,9 @@ local reply; local code, body = response.code, response.body; - if code == 202 or code == 204 then + if not reply_allowed then + return; + elseif code == 202 or code == 204 then if not reply_needed then -- Delivered, no reply return;