(finish_msg): Make sure part header is preserved.
Showing
1 changed file
with
50 additions
and
21 deletions
... | @@ -1993,6 +1993,53 @@ parse_type_command (char **pcmd, struct compose_env *env, mu_header_t hdr) | ... | @@ -1993,6 +1993,53 @@ parse_type_command (char **pcmd, struct compose_env *env, mu_header_t hdr) |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | void | 1995 | void |
1996 | copy_header (mu_message_t msg, mu_header_t out) | ||
1997 | { | ||
1998 | size_t i, count; | ||
1999 | mu_header_t hdr; | ||
2000 | |||
2001 | mu_message_get_header (msg, &hdr); | ||
2002 | mu_header_get_field_count (hdr, &count); | ||
2003 | for (i = 1; i <= count; i++) | ||
2004 | { | ||
2005 | char *name, *value; | ||
2006 | |||
2007 | if (mu_header_aget_field_name (hdr, i, &name)) | ||
2008 | continue; | ||
2009 | |||
2010 | if (mu_header_aget_field_value (hdr, i, &value)) | ||
2011 | { | ||
2012 | free (name); | ||
2013 | continue; | ||
2014 | } | ||
2015 | |||
2016 | mu_header_set_value (out, name, value, 0); | ||
2017 | free (name); | ||
2018 | free (value); | ||
2019 | } | ||
2020 | } | ||
2021 | |||
2022 | void | ||
2023 | copy_header_to_stream (mu_message_t msg, mu_stream_t stream) | ||
2024 | { | ||
2025 | mu_header_t hdr; | ||
2026 | mu_stream_t in; | ||
2027 | char *buf = NULL; | ||
2028 | size_t bufsize = 0, n = 0; | ||
2029 | |||
2030 | mu_message_get_header (msg, &hdr); | ||
2031 | mu_header_get_stream (hdr, &in); | ||
2032 | mu_stream_seek (in, 0, SEEK_SET); | ||
2033 | while (stream_getline (in, &buf, &bufsize, &n) == 0 && n > 0) | ||
2034 | { | ||
2035 | if (n == 1 && buf[0] == '\n') | ||
2036 | break; | ||
2037 | mu_stream_sequential_write (stream, buf, n); | ||
2038 | } | ||
2039 | free (buf); | ||
2040 | } | ||
2041 | |||
2042 | void | ||
1996 | finish_msg (struct compose_env *env, mu_message_t *msg) | 2043 | finish_msg (struct compose_env *env, mu_message_t *msg) |
1997 | { | 2044 | { |
1998 | mu_header_t hdr; | 2045 | mu_header_t hdr; |
... | @@ -2026,6 +2073,8 @@ finish_text_msg (struct compose_env *env, mu_message_t *msg, int ascii) | ... | @@ -2026,6 +2073,8 @@ finish_text_msg (struct compose_env *env, mu_message_t *msg, int ascii) |
2026 | 2073 | ||
2027 | mu_message_create (&newmsg, NULL); | 2074 | mu_message_create (&newmsg, NULL); |
2028 | mu_message_get_header (newmsg, &hdr); | 2075 | mu_message_get_header (newmsg, &hdr); |
2076 | mu_header_get_stream (hdr, &output); | ||
2077 | copy_header (*msg, hdr); | ||
2029 | mu_header_set_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING, | 2078 | mu_header_set_value (hdr, MU_HEADER_CONTENT_TRANSFER_ENCODING, |
2030 | "quoted-printable", 0); | 2079 | "quoted-printable", 0); |
2031 | 2080 | ||
... | @@ -2492,26 +2541,6 @@ mhn_edit (struct compose_env *env, int level) | ... | @@ -2492,26 +2541,6 @@ mhn_edit (struct compose_env *env, int level) |
2492 | return status; | 2541 | return status; |
2493 | } | 2542 | } |
2494 | 2543 | ||
2495 | void | ||
2496 | copy_header (mu_message_t msg, mu_stream_t stream) | ||
2497 | { | ||
2498 | mu_header_t hdr; | ||
2499 | mu_stream_t in; | ||
2500 | char *buf = NULL; | ||
2501 | size_t bufsize = 0, n = 0; | ||
2502 | |||
2503 | mu_message_get_header (msg, &hdr); | ||
2504 | mu_header_get_stream (hdr, &in); | ||
2505 | mu_stream_seek (in, 0, SEEK_SET); | ||
2506 | while (stream_getline (in, &buf, &bufsize, &n) == 0 && n > 0) | ||
2507 | { | ||
2508 | if (n == 1 && buf[0] == '\n') | ||
2509 | break; | ||
2510 | mu_stream_sequential_write (stream, buf, n); | ||
2511 | } | ||
2512 | free (buf); | ||
2513 | } | ||
2514 | |||
2515 | int | 2544 | int |
2516 | parse_header_directive (char *val, char **encoding, char **charset, char **subject) | 2545 | parse_header_directive (char *val, char **encoding, char **charset, char **subject) |
2517 | { | 2546 | { |
... | @@ -2705,7 +2734,7 @@ mhn_compose () | ... | @@ -2705,7 +2734,7 @@ mhn_compose () |
2705 | } | 2734 | } |
2706 | 2735 | ||
2707 | mhn_header (message, msg); | 2736 | mhn_header (message, msg); |
2708 | copy_header (message, stream); | 2737 | copy_header_to_stream (message, stream); |
2709 | mu_message_get_stream (msg, &in); | 2738 | mu_message_get_stream (msg, &in); |
2710 | cat_message (stream, in); | 2739 | cat_message (stream, in); |
2711 | mu_stream_destroy (&stream, mu_stream_get_owner (stream)); | 2740 | mu_stream_destroy (&stream, mu_stream_get_owner (stream)); | ... | ... |
-
Please register or sign in to post a comment