mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Fixed problem with using id attribute with apostrophe.
Needs a better solution, but the current one stop the crash
This commit is contained in:
parent
6acbb5e512
commit
5c475d630a
@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gprintf.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "config/preferences.h"
|
||||
@ -36,6 +37,8 @@
|
||||
#include "xmpp/stanza.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
|
||||
#include "ui/ui.h"
|
||||
|
||||
static GHashTable *sub_requests;
|
||||
|
||||
#define HANDLE(ns, type, func) xmpp_handler_add(conn, func, ns, \
|
||||
@ -462,6 +465,10 @@ _get_caps_key(xmpp_stanza_t * const stanza)
|
||||
char *caps_key = NULL;
|
||||
char *node = NULL;
|
||||
char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
guint from_hash = g_str_hash(from);
|
||||
char from_hash_str[100];
|
||||
g_sprintf(from_hash_str, "%d", from_hash);
|
||||
|
||||
if (stanza_contains_caps(stanza)) {
|
||||
log_debug("Presence contains capabilities.");
|
||||
char *hash_type = stanza_caps_get_hash(stanza);
|
||||
@ -494,14 +501,14 @@ _get_caps_key(xmpp_stanza_t * const stanza)
|
||||
} else {
|
||||
log_debug("Hash type unsupported.");
|
||||
node = stanza_get_caps_str(stanza);
|
||||
caps_key = from;
|
||||
caps_key = from_hash_str;
|
||||
|
||||
if (node != NULL) {
|
||||
log_debug("Node string: %s.", node);
|
||||
if (!caps_contains(caps_key)) {
|
||||
log_debug("Capabilities not cached for '%s', sending discovery IQ.", caps_key);
|
||||
GString *id = g_string_new("disco_");
|
||||
g_string_append(id, from);
|
||||
g_string_append(id, from_hash_str);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_iq(ctx, id->str, from, node);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
@ -520,14 +527,14 @@ _get_caps_key(xmpp_stanza_t * const stanza)
|
||||
} else {
|
||||
log_debug("No hash type, using legacy capabilities.");
|
||||
node = stanza_get_caps_str(stanza);
|
||||
caps_key = from;
|
||||
caps_key = from_hash_str;
|
||||
|
||||
if (node != NULL) {
|
||||
log_debug("Node string: %s.", node);
|
||||
if (!caps_contains(caps_key)) {
|
||||
log_debug("Capabilities not cached for '%s', sending discovery IQ.", caps_key);
|
||||
GString *id = g_string_new("disco_");
|
||||
g_string_append(id, from);
|
||||
g_string_append(id, from_hash_str);
|
||||
xmpp_stanza_t *iq = stanza_create_disco_iq(ctx, id->str, from, node);
|
||||
xmpp_send(conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
|
Loading…
Reference in New Issue
Block a user