diff options
author | James Booth <boothj5@gmail.com> | 2012-11-06 22:53:59 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-11-06 22:53:59 +0000 |
commit | 92ae93de33087c57a23a63af45402a509f4443cd (patch) | |
tree | 3763594712254c8d7ab1b7cc982959774525a622 /src/jabber.c | |
parent | 9872708755c967ca228e0ce4ee7fa5adb7dd039c (diff) | |
download | profani-tty-92ae93de33087c57a23a63af45402a509f4443cd.tar.gz |
Tidied escaping xml
Diffstat (limited to 'src/jabber.c')
-rw-r--r-- | src/jabber.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/jabber.c b/src/jabber.c index 3b1b9be3..3f216441 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -144,9 +144,7 @@ jabber_send(const char * const msg, const char * const recipient) } } - char *coded_msg = str_replace(msg, "&", "&"); - char *coded_msg2 = str_replace(coded_msg, "<", "<"); - char *coded_msg3 = str_replace(coded_msg2, ">", ">"); + char *encoded_xml = encode_xml(msg); xmpp_stanza_t *reply, *body, *text, *active; @@ -159,7 +157,7 @@ jabber_send(const char * const msg, const char * const recipient) xmpp_stanza_set_name(body, "body"); text = xmpp_stanza_new(jabber_conn.ctx); - xmpp_stanza_set_text(text, coded_msg3); + xmpp_stanza_set_text(text, encoded_xml); if (prefs_get_states()) { @@ -178,17 +176,14 @@ jabber_send(const char * const msg, const char * const recipient) xmpp_send(jabber_conn.conn, reply); xmpp_stanza_release(reply); - free(coded_msg); - free(coded_msg2); - free(coded_msg3); + + free(encoded_xml); } void jabber_send_groupchat(const char * const msg, const char * const recipient) { - char *coded_msg = str_replace(msg, "&", "&"); - char *coded_msg2 = str_replace(coded_msg, "<", "<"); - char *coded_msg3 = str_replace(coded_msg2, ">", ">"); + char *encoded_xml = encode_xml(msg); xmpp_stanza_t *reply, *body, *text; @@ -201,16 +196,15 @@ jabber_send_groupchat(const char * const msg, const char * const recipient) xmpp_stanza_set_name(body, "body"); text = xmpp_stanza_new(jabber_conn.ctx); - xmpp_stanza_set_text(text, coded_msg3); + xmpp_stanza_set_text(text, encoded_xml); xmpp_stanza_add_child(body, text); xmpp_stanza_add_child(reply, body); xmpp_send(jabber_conn.conn, reply); xmpp_stanza_release(reply); - free(coded_msg); - free(coded_msg2); - free(coded_msg3); + + free(encoded_xml); } void |