diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-07-02 17:47:07 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-07-02 17:47:07 +0200 |
commit | 6be5b51a46d1598ac12ddda88b36a2487bf523e0 (patch) | |
tree | 887d43c37e6637529a7c3b20c6017e2a7cde0389 /src/xmpp | |
parent | 46a00317ee85be02fc9174315db24297079d5c4d (diff) | |
download | profani-tty-6be5b51a46d1598ac12ddda88b36a2487bf523e0.tar.gz |
message.c: Log invalid message type
So far we logged when we receive a message without a type. Which is actually quite common and makes no sense.
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/message.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 82d8c599..42507b91 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -109,23 +109,11 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con xmpp_free(connection_get_ctx(), text); return 1; } + xmpp_free(connection_get_ctx(), text); // type according to RFC 6121 const char *type = xmpp_stanza_get_type(stanza); - if (type == NULL) { - if (_handle_mam(stanza)) { - xmpp_free(connection_get_ctx(), text); - return 1; - } - - log_info("Received <message> without 'type': %s", text); - xmpp_free(connection_get_ctx(), text); - return 1; - } - - xmpp_free(connection_get_ctx(), text); - if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { _handle_error(stanza); } else if (g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0) { @@ -136,6 +124,11 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con } else if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) != 0 || g_strcmp0(type, STANZA_TYPE_NORMAL) != 0 ) { // type: chat, normal (==NULL) + // XEP-0313: Message Archive Management + if (_handle_mam(stanza)) { + return 1; + } + // XEP-0045: Multi-User Chat - invites - presence xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); if (mucuser) { @@ -172,7 +165,14 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con _handle_chat(stanza, FALSE); } else { - log_info("Received <message> without 'type': %s", text); + // none of the allowed types + char *text; + size_t text_size; + + xmpp_stanza_to_text(stanza, &text, &text_size); + log_info("Received <message> with invalid 'type': %s", text); + + xmpp_free(connection_get_ctx(), text); } return 1; |