From 30b1d27fc122eee1cacc1d25dd580ac416b81783 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 8 Mar 2021 21:04:21 +0100 Subject: [PATCH 1/2] XEP-0004: stanza, only delete field type if it is not 'hidden' Not strictly required, but most XEPs use it like that for forms of type='submit', and that makes it easier to write stanza tests. --- slixmpp/plugins/xep_0004/stanza/form.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/slixmpp/plugins/xep_0004/stanza/form.py b/slixmpp/plugins/xep_0004/stanza/form.py index 84c89173..c04193f0 100644 --- a/slixmpp/plugins/xep_0004/stanza/form.py +++ b/slixmpp/plugins/xep_0004/stanza/form.py @@ -48,7 +48,8 @@ class Form(ElementBase): fields = self.get_fields() for var in fields: field = fields[var] - del field['type'] + if field['type'] != 'hidden': + del field['type'] del field['label'] del field['desc'] del field['required'] @@ -74,7 +75,8 @@ class Form(ElementBase): for option in options: field.add_option(**option) else: - del field['type'] + if field['type'] != 'hidden': + del field['type'] self.append(field) return field From 432a3326362775b171ceb3466cb7fb28312e4798 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 8 Mar 2021 21:06:43 +0100 Subject: [PATCH 2/2] tests: Fix XEP-0060 tests for the new 0004 change regarding type attribute --- tests/test_stanza_xep_0060.py | 2 +- tests/test_stream_xep_0060.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_stanza_xep_0060.py b/tests/test_stanza_xep_0060.py index d05bc3d0..671f9cd0 100644 --- a/tests/test_stanza_xep_0060.py +++ b/tests/test_stanza_xep_0060.py @@ -314,7 +314,7 @@ class TestPubsubStanzas(SlixTest): - + http://jabber.org/protocol/pubsub#node_config diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py index da543f96..a5fd0bdc 100644 --- a/tests/test_stream_xep_0060.py +++ b/tests/test_stream_xep_0060.py @@ -72,7 +72,7 @@ class TestStreamPubsub(SlixTest): whitelist - + http://jabber.org/protocol/pubsub#node_config @@ -210,7 +210,7 @@ class TestStreamPubsub(SlixTest): - + http://jabber.org/protocol/pubsub#subscribe_options @@ -358,7 +358,7 @@ class TestStreamPubsub(SlixTest): - + http://jabber.org/protocol/pubsub#node_config @@ -441,7 +441,7 @@ class TestStreamPubsub(SlixTest): - + http://jabber.org/protocol/pubsub#publish-options @@ -622,7 +622,7 @@ class TestStreamPubsub(SlixTest): - + http://jabber.org/protocol/pubsub#subscribe_options