about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--src/ui/core.c2
-rw-r--r--src/xmpp/form.c106
3 files changed, 58 insertions, 54 deletions
diff --git a/.gitignore b/.gitignore
index 955952c3..b5980f6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,5 +57,7 @@ pageing.txt
 cppcheck.out
 gitpushall.sh
 Debug/
-profanity.mk
 compile_commands.json
+profanity.mk
+profanity.project
+profanity.workspace
diff --git a/src/ui/core.c b/src/ui/core.c
index bd3c5d85..dc4ab885 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -2034,7 +2034,7 @@ _ui_show_form(ProfWin *window, const char * const room, DataForm *form)
     while (curr_field != NULL) {
         FormField *field = curr_field->data;
 
-        if (g_strcmp0(field->type, "hidden") != 0) {
+        if (g_strcmp0(field->type, "hidden") != 0 && field->var) {
             char *tag = g_hash_table_lookup(form->var_to_tag, field->var);
             _ui_handle_form_field(window, tag, field);
         }
diff --git a/src/xmpp/form.c b/src/xmpp/form.c
index 7a3baad2..e4f336e9 100644
--- a/src/xmpp/form.c
+++ b/src/xmpp/form.c
@@ -211,7 +211,7 @@ form_create(xmpp_stanza_t * const form_stanza)
 
             field->var = _get_attr(field_stanza, "var");
 
-            if (field->type_t != FIELD_HIDDEN) {
+            if (field->type_t != FIELD_HIDDEN && field->var != NULL) {
                 GString *tag = g_string_new("");
                 g_string_printf(tag, "field%d", tag_num++);
                 g_hash_table_insert(form->var_to_tag, strdup(field->var), strdup(tag->str));
@@ -287,64 +287,66 @@ form_create_submission(DataForm *form)
     while (curr_field) {
         FormField *field = curr_field->data;
 
-        xmpp_stanza_t *field_stanza = xmpp_stanza_new(ctx);
-        xmpp_stanza_set_name(field_stanza, "field");
-        xmpp_stanza_set_attribute(field_stanza, "var", field->var);
-
-        xmpp_stanza_t *value_stanza = NULL;
-        GSList *curr_value = NULL;
-
-        switch (field->type_t) {
-            case FIELD_HIDDEN:
-            case FIELD_FIXED:
-            case FIELD_TEXT_SINGLE:
-            case FIELD_TEXT_PRIVATE:
-            case FIELD_BOOLEAN:
-            case FIELD_LIST_SINGLE:
-            case FIELD_JID_SINGLE:
-                value_stanza = xmpp_stanza_new(ctx);
-                xmpp_stanza_set_name(value_stanza, "value");
-                if (field->values) {
-                    if (field->values->data) {
-                        xmpp_stanza_t *text_stanza = xmpp_stanza_new(ctx);
-                        xmpp_stanza_set_text(text_stanza, field->values->data);
-                        xmpp_stanza_add_child(value_stanza, text_stanza);
-                        xmpp_stanza_release(text_stanza);
-                    }
-                }
-                xmpp_stanza_add_child(field_stanza, value_stanza);
-                xmpp_stanza_release(value_stanza);
-
-                break;
-
-            case FIELD_TEXT_MULTI:
-            case FIELD_LIST_MULTI:
-            case FIELD_JID_MULTI:
-                curr_value = field->values;
-                while (curr_value) {
-                    char *value = curr_value->data;
-
+        if (field->type_t != FIELD_FIXED) {
+            xmpp_stanza_t *field_stanza = xmpp_stanza_new(ctx);
+            xmpp_stanza_set_name(field_stanza, "field");
+            xmpp_stanza_set_attribute(field_stanza, "var", field->var);
+
+            xmpp_stanza_t *value_stanza = NULL;
+            GSList *curr_value = NULL;
+
+            switch (field->type_t) {
+                case FIELD_HIDDEN:
+                case FIELD_TEXT_SINGLE:
+                case FIELD_TEXT_PRIVATE:
+                case FIELD_BOOLEAN:
+                case FIELD_LIST_SINGLE:
+                case FIELD_JID_SINGLE:
                     value_stanza = xmpp_stanza_new(ctx);
                     xmpp_stanza_set_name(value_stanza, "value");
-                    if (value) {
-                        xmpp_stanza_t *text_stanza = xmpp_stanza_new(ctx);
-                        xmpp_stanza_set_text(text_stanza, value);
-                        xmpp_stanza_add_child(value_stanza, text_stanza);
-                        xmpp_stanza_release(text_stanza);
+                    if (field->values) {
+                        if (field->values->data) {
+                            xmpp_stanza_t *text_stanza = xmpp_stanza_new(ctx);
+                            xmpp_stanza_set_text(text_stanza, field->values->data);
+                            xmpp_stanza_add_child(value_stanza, text_stanza);
+                            xmpp_stanza_release(text_stanza);
+                        }
                     }
-
                     xmpp_stanza_add_child(field_stanza, value_stanza);
                     xmpp_stanza_release(value_stanza);
 
-                    curr_value = g_slist_next(curr_value);
-                }
-                break;
-            default:
-                break;
-        }
+                    break;
+
+                case FIELD_TEXT_MULTI:
+                case FIELD_LIST_MULTI:
+                case FIELD_JID_MULTI:
+                    curr_value = field->values;
+                    while (curr_value) {
+                        char *value = curr_value->data;
+
+                        value_stanza = xmpp_stanza_new(ctx);
+                        xmpp_stanza_set_name(value_stanza, "value");
+                        if (value) {
+                            xmpp_stanza_t *text_stanza = xmpp_stanza_new(ctx);
+                            xmpp_stanza_set_text(text_stanza, value);
+                            xmpp_stanza_add_child(value_stanza, text_stanza);
+                            xmpp_stanza_release(text_stanza);
+                        }
+
+                        xmpp_stanza_add_child(field_stanza, value_stanza);
+                        xmpp_stanza_release(value_stanza);
 
-        xmpp_stanza_add_child(x, field_stanza);
-        xmpp_stanza_release(field_stanza);
+                        curr_value = g_slist_next(curr_value);
+                    }
+                    break;
+                case FIELD_FIXED:
+                default:
+                    break;
+            }
+
+            xmpp_stanza_add_child(x, field_stanza);
+            xmpp_stanza_release(field_stanza);
+        }
 
         curr_field = g_slist_next(curr_field);
     }