diff options
author | Michael Elkins <me@sigpipe.org> | 2013-01-17 23:03:29 +0000 |
---|---|---|
committer | Michael Elkins <me@sigpipe.org> | 2013-01-17 23:03:29 +0000 |
commit | f0ce592ebf5ac5614227960880244148a36fc29f (patch) | |
tree | 0fac22474ad3b3d8893c6b6ff8aabb2f3c900b96 | |
parent | 9736319d31cd9ee8d9fcb85199d80a5620d5161d (diff) |
when falling back to viewing an attachment as text in the internal pager, perform charset conversion
this change is meant to replace [392e945dfba7]
see #3234
see #3293
-rw-r--r-- | attach.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -504,9 +504,27 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr, if (flag == M_AS_TEXT) { - /* just let me see the raw data */ - if (mutt_save_attachment (fp, a, pagerfile, 0, NULL)) + /* just let me see the raw data. + * + * Don't use mutt_save_attachment() because we want to perform charset + * conversion since this will be displayed by the internal pager. + */ + STATE decode_state; + + memset(&decode_state, 0, sizeof(decode_state)); + decode_state.fpout = safe_fopen(pagerfile, "w"); + if (!decode_state.fpout) + { + dprint(1, (debugfile, "mutt_view_attachment:%d safe_fopen(%s) errno=%d %s\n", __LINE__, pagerfile, errno, strerror(errno))); + mutt_perror(pagerfile); + mutt_sleep(1); goto return_error; + } + decode_state.fpin = fp; + decode_state.flags = M_CHARCONV; + mutt_decode_attachment(a, &decode_state); + if (fclose(decode_state.fpout) == EOF) + dprint(1, (debugfile, "mutt_view_attachment:%d fclose errno=%d %s\n", __LINE__, pagerfile, errno, strerror(errno))); } else { |