1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added xml escaping to stanza module

This commit is contained in:
James Booth 2012-11-08 23:35:11 +00:00
parent 29b5abfe06
commit f90d13bd5e
2 changed files with 9 additions and 7 deletions

View File

@ -144,8 +144,6 @@ jabber_process_events(void)
void
jabber_send(const char * const msg, const char * const recipient)
{
char *encoded_xml = encode_xml(msg);
if (prefs_get_states()) {
if (!chat_session_exists(recipient)) {
chat_session_start(recipient, TRUE);
@ -156,16 +154,14 @@ jabber_send(const char * const msg, const char * const recipient)
if (prefs_get_states() && chat_session_get_recipient_supports(recipient)) {
chat_session_set_active(recipient);
message = stanza_create_message(jabber_conn.ctx, recipient, "chat",
encoded_xml, "active");
msg, "active");
} else {
message = stanza_create_message(jabber_conn.ctx, recipient, "chat",
encoded_xml, NULL);
msg, NULL);
}
xmpp_send(jabber_conn.conn, message);
xmpp_stanza_release(message);
free(encoded_xml);
}
void

View File

@ -22,6 +22,8 @@
#include <strophe.h>
#include "common.h"
xmpp_stanza_t *
stanza_create_chat_state(xmpp_ctx_t *ctx, const char * const recipient,
const char * const state)
@ -46,6 +48,8 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient,
const char * const type, const char * const message,
const char * const state)
{
char *encoded_xml = encode_xml(message);
xmpp_stanza_t *msg, *body, *text;
msg = xmpp_stanza_new(ctx);
@ -57,7 +61,7 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient,
xmpp_stanza_set_name(body, "body");
text = xmpp_stanza_new(ctx);
xmpp_stanza_set_text(text, message);
xmpp_stanza_set_text(text, encoded_xml);
xmpp_stanza_add_child(body, text);
xmpp_stanza_add_child(msg, body);
@ -68,6 +72,8 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient,
xmpp_stanza_add_child(msg, chat_state);
}
g_free(encoded_xml);
return msg;
}