Dzięki tej zmianie formatowanie w odebranych wiadomościach m.in. od Infobota jest poprawne. --- src/handlers.c | 15 ++++++++++++--- test/automatic/script/20-messages.scr | 30 ++++++++++++++++-------------- 2 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/src/handlers.c b/src/handlers.c index 2e53b70..962f265 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -946,9 +946,9 @@ static int gg_session_handle_recv_msg_80(struct gg_session *sess, uint32_t type, } } else { if (offset_plain > sizeof(struct gg_recv_msg80)) { - size_t len; + size_t len, fmt_len; - len = gg_message_html_to_text(NULL, NULL, NULL, packet + sizeof(struct gg_recv_msg80)); + len = gg_message_html_to_text(NULL, NULL, &fmt_len, packet + sizeof(struct gg_recv_msg80)); e->event.msg.message = malloc(len + 1); if (e->event.msg.message == NULL) { @@ -956,7 +956,16 @@ static int gg_session_handle_recv_msg_80(struct gg_session *sess, uint32_t type, goto fail; } - gg_message_html_to_text((char*) e->event.msg.message, NULL, NULL, packet + sizeof(struct gg_recv_msg80)); + free(e->event.msg.formats); + e->event.msg.formats_length = fmt_len; + e->event.msg.formats = malloc(fmt_len); + + if (e->event.msg.formats == NULL) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_session_handle_recv_msg_80() out of memory\n"); + goto fail; + } + + gg_message_html_to_text((char*) e->event.msg.message, e->event.msg.formats, NULL, packet + sizeof(struct gg_recv_msg80)); } else { e->event.msg.message = (unsigned char*) gg_encoding_convert(packet + offset_plain, GG_ENCODING_CP1250, sess->encoding, -1, -1); diff --git a/test/automatic/script/20-messages.scr b/test/automatic/script/20-messages.scr index c659b33..acaf7ec 100644 --- a/test/automatic/script/20-messages.scr +++ b/test/automatic/script/20-messages.scr @@ -59,8 +59,10 @@ expect event GG_EVENT_MSG ( msg.recipients_count == 0 msg.recipients == NULL - msg.formats_length == 0 - msg.formats == NULL + msg.formats_length == 3 + msg.formats[0] == (char) 0x00 + msg.formats[1] == (char) 0x00 + msg.formats[2] == (char) 0x01 ) expect data (46 00 00 00, auto, 22 22 22 22) @@ -82,11 +84,10 @@ expect event GG_EVENT_MSG ( msg.recipients_count == 0 msg.recipients == NULL - msg.formats_length == 4 - msg.formats[0] == (char) 0x12 - msg.formats[1] == (char) 0x34 - msg.formats[2] == (char) 0x56 - msg.formats[3] == (char) 0x78 + msg.formats_length == 3 + msg.formats[0] == (char) 0x00 + msg.formats[1] == (char) 0x00 + msg.formats[2] == (char) 0x01 ) expect data (46 00 00 00, auto, 22 22 00 22) @@ -110,8 +111,10 @@ expect event GG_EVENT_MSG ( msg.recipients[1] == (int) 2 msg.recipients[2] == (int) 3 - msg.formats_length == 0 - msg.formats == NULL + msg.formats_length == 3 + msg.formats[0] == (char) 0x00 + msg.formats[1] == (char) 0x00 + msg.formats[2] == (char) 0x01 ) expect data (46 00 00 00, auto, xx xx xx xx) @@ -169,11 +172,10 @@ expect event GG_EVENT_MSG ( msg.recipients[1] == (int) 2 msg.recipients[2] == (int) 3 - msg.formats_length == 4 - msg.formats[0] == (char) 0x12 - msg.formats[1] == (char) 0x34 - msg.formats[2] == (char) 0x56 - msg.formats[3] == (char) 0x78 + msg.formats_length == 3 + msg.formats[0] == (char) 0x00 + msg.formats[1] == (char) 0x00 + msg.formats[2] == (char) 0x01 ) expect data (46 00 00 00, auto, xx xx xx xx) -- 1.7.6.1 _______________________________________________ libgadu-devel mailing list libgadu-devel@lists.ziew.org http://lists.ziew.org/mailman/listinfo/libgadu-devel