diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2016-10-25 17:35:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-25 17:35:15 +0100 |
commit | 4b67f72d4ca35a9f793cba7d20efbcb0dd0913d6 (patch) | |
tree | 6954b7db6eafdd9912be41e9551b2f8fce65db6e | |
parent | fec47901e1bf02664ceaf41672b50f3c1f9b56d7 (diff) | |
parent | 576ea63619c672ff1a110d0775e5c7413890eace (diff) | |
download | purple-matrix-4b67f72d4ca35a9f793cba7d20efbcb0dd0913d6.tar.gz |
Merge pull request #19 from brycied00d/HTML_Escape_Fix
Unescape the HTML-escaped HTML.
-rw-r--r-- | matrix-room.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/matrix-room.c b/matrix-room.c index 89db8e5..6505b30 100644 --- a/matrix-room.c +++ b/matrix-room.c @@ -987,8 +987,8 @@ void matrix_room_send_message(PurpleConversation *conv, const gchar *message) JsonObject *content; PurpleConvChat *chat = PURPLE_CONV_CHAT(conv); const char *type_string = "m.text"; - const gchar *message_to_send = message; const char *image_start, *image_end; + gchar *message_to_send; GData *image_attribs; /* Matrix doesn't have messages that have both images and text in, so @@ -1020,9 +1020,14 @@ void matrix_room_send_message(PurpleConversation *conv, const gchar *message) return; } - if (!strncmp(message, "/me ", 4)) { + /* Matrix messages are JSON-encoded, so there's no need to HTML/XML- + * escape the message body. Matrix clients don't unescape the bodies + * either, so they end up seeing " instead of " + */ + message_to_send = purple_unescape_html(message); + + if (purple_message_meify(message_to_send, -1)) { type_string = "m.emote"; - message_to_send = message + 4; } content = json_object_new(); @@ -1034,4 +1039,5 @@ void matrix_room_send_message(PurpleConversation *conv, const gchar *message) purple_conv_chat_write(chat, _get_my_display_name(conv), message, PURPLE_MESSAGE_SEND, g_get_real_time()/1000/1000); + g_free(message_to_send); } |