Changeset

11770:d2a9aa1c7ac8

mod_c2s,mod_s2s: Indicate stanza size violation with condition from XEP-0205 (thanks mjk)
author Kim Alvefur <zash@zash.se>
date Mon, 06 Sep 2021 23:21:25 +0200
parents 11769:071715a18394
children 11771:4c0802b52673
files doc/doap.xml plugins/mod_c2s.lua plugins/mod_s2s.lua
diffstat 3 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/doc/doap.xml	Sun Sep 05 18:42:44 2021 +0200
+++ b/doc/doap.xml	Mon Sep 06 23:21:25 2021 +0200
@@ -446,6 +446,13 @@
     </implements>
     <implements>
       <xmpp:SupportedXep>
+        <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0205.html"/>
+        <xmpp:since>0.12.0</xmpp:since>
+        <xmpp:note>stanza size limits, bandwidth limits, stanza-too-big error condition</xmpp:note>
+      </xmpp:SupportedXep>
+    </implements>
+    <implements>
+      <xmpp:SupportedXep>
         <xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0206.html"/>
         <xmpp:version>1.2</xmpp:version>
         <xmpp:since>0.2.0</xmpp:since>
--- a/plugins/mod_c2s.lua	Sun Sep 05 18:42:44 2021 +0200
+++ b/plugins/mod_c2s.lua	Mon Sep 06 23:21:25 2021 +0200
@@ -339,7 +339,11 @@
 				if not ok then
 					log("debug", "Received invalid XML (%s) %d bytes: %q", err, #data, data:sub(1, 300));
 					if err == "stanza-too-large" then
-						session:close({ condition = "policy-violation", text = "XML stanza is too big" });
+						session:close({
+							condition = "policy-violation",
+							text = "XML stanza is too big",
+							extra = st.stanza("stanza-too-big", { xmlns = 'urn:xmpp:errors' }),
+						});
 					else
 						session:close("not-well-formed");
 					end
--- a/plugins/mod_s2s.lua	Sun Sep 05 18:42:44 2021 +0200
+++ b/plugins/mod_s2s.lua	Mon Sep 06 23:21:25 2021 +0200
@@ -746,7 +746,11 @@
 			if ok then return; end
 			log("debug", "Received invalid XML (%s) %d bytes: %q", err, #data, data:sub(1, 300));
 			if err == "stanza-too-large" then
-				session:close({ condition = "policy-violation", text = "XML stanza is too big" }, nil, "Received invalid XML from remote server");
+				session:close({
+					condition = "policy-violation",
+					text = "XML stanza is too big",
+					extra = st.stanza("stanza-too-big", { xmlns = 'urn:xmpp:errors' }),
+				}, nil, "Received invalid XML from remote server");
 			else
 				session:close("not-well-formed", nil, "Received invalid XML from remote server");
 			end