diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-11-28 07:00:13 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-11-28 07:00:13 +0000 |
commit | f0b2eb198def2bb1674b1e5b3ad82f645d68e289 (patch) | |
tree | ae895e55981f8957200781ae4620803718cc1a8e | |
parent | 928a2cc8708a85a7fbcceb4d77e163835b158934 (diff) |
also normalize text files on win32 when saving parts.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@784 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ChangeLog.ja | 6 | ||||
-rw-r--r-- | libsylph/procmime.c | 79 |
3 files changed, 64 insertions, 26 deletions
@@ -1,5 +1,10 @@ 2005-11-28 + * libsylph/procmime.c: procmime_decode_content(): also normalize text + files on win32. Also do normalization for quoted-printable part. + +2005-11-28 + * libsylph/pop.c libsylph/recv.c src/compose.c: reverted linebreak conversion. diff --git a/ChangeLog.ja b/ChangeLog.ja index 7ea51743..4e5907fc 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,11 @@ 2005-11-28 + * libsylph/procmime.c: procmime_decode_content(): win32 でもテキスト + ファイルを正規化するようにした。 quoted-printable のパートでも + 正規化を行うようにした。 + +2005-11-28 + * libsylph/pop.c libsylph/recv.c src/compose.c: 改行の変換を元に戻した。 diff --git a/libsylph/procmime.c b/libsylph/procmime.c index 6207807e..13df59bd 100644 --- a/libsylph/procmime.c +++ b/libsylph/procmime.c @@ -543,6 +543,8 @@ FILE *procmime_decode_content(FILE *outfp, FILE *infp, MimeInfo *mimeinfo) gchar *boundary = NULL; gint boundary_len = 0; gboolean tmp_file = FALSE; + gboolean normalize_lbreak = FALSE; + ContentType content_type; g_return_val_if_fail(infp != NULL, NULL); g_return_val_if_fail(mimeinfo != NULL, NULL); @@ -561,27 +563,53 @@ FILE *procmime_decode_content(FILE *outfp, FILE *infp, MimeInfo *mimeinfo) boundary_len = strlen(boundary); } + content_type = procmime_scan_mime_type(mimeinfo->content_type); + if (content_type == MIME_TEXT || + content_type == MIME_TEXT_HTML) { + normalize_lbreak = TRUE; + } + if (mimeinfo->encoding_type == ENC_QUOTED_PRINTABLE) { + FILE *tmpfp = outfp; + + if (normalize_lbreak) { + tmpfp = my_tmpfile(); + if (!tmpfp) { + perror("tmpfile"); + if (tmp_file) fclose(outfp); + return NULL; + } + } + while (fgets(buf, sizeof(buf), infp) != NULL && (!boundary || !IS_BOUNDARY(buf, boundary, boundary_len))) { gint len; len = qp_decode_line(buf); - fwrite(buf, len, 1, outfp); + fwrite(buf, len, 1, tmpfp); + } + + if (normalize_lbreak) { + rewind(tmpfp); + while (fgets(buf, sizeof(buf), tmpfp) != NULL) { +#ifdef G_OS_WIN32 + strretchomp(buf); + fputs(buf, outfp); + fputs("\r\n", outfp); +#else + strcrchomp(buf); + fputs(buf, outfp); +#endif + } + fclose(tmpfp); } } else if (mimeinfo->encoding_type == ENC_BASE64) { gchar outbuf[BUFFSIZE]; gint len; Base64Decoder *decoder; FILE *tmpfp = outfp; -#ifndef G_OS_WIN32 - gboolean uncanonicalize = FALSE; - ContentType content_type; - - content_type = procmime_scan_mime_type(mimeinfo->content_type); - if (content_type == MIME_TEXT || - content_type == MIME_TEXT_HTML) { - uncanonicalize = TRUE; + + if (normalize_lbreak) { tmpfp = my_tmpfile(); if (!tmpfp) { perror("tmpfile"); @@ -589,7 +617,6 @@ FILE *procmime_decode_content(FILE *outfp, FILE *infp, MimeInfo *mimeinfo) return NULL; } } -#endif decoder = base64_decoder_new(); while (fgets(buf, sizeof(buf), infp) != NULL && @@ -605,16 +632,20 @@ FILE *procmime_decode_content(FILE *outfp, FILE *infp, MimeInfo *mimeinfo) } base64_decoder_free(decoder); -#ifndef G_OS_WIN32 - if (uncanonicalize) { + if (normalize_lbreak) { rewind(tmpfp); while (fgets(buf, sizeof(buf), tmpfp) != NULL) { +#ifdef G_OS_WIN32 + strretchomp(buf); + fputs(buf, outfp); + fputs("\r\n", outfp); +#else strcrchomp(buf); fputs(buf, outfp); +#endif } fclose(tmpfp); } -#endif } else if (mimeinfo->encoding_type == ENC_X_UUENCODE) { gchar outbuf[BUFFSIZE]; gint len; @@ -637,24 +668,20 @@ FILE *procmime_decode_content(FILE *outfp, FILE *infp, MimeInfo *mimeinfo) flag = TRUE; } } else { -#ifndef G_OS_WIN32 - gboolean uncanonicalize = FALSE; - ContentType content_type; - - content_type = procmime_scan_mime_type(mimeinfo->content_type); - if (content_type == MIME_TEXT || - content_type == MIME_TEXT_HTML) - uncanonicalize = TRUE; -#endif - while (fgets(buf, sizeof(buf), infp) != NULL && (!boundary || !IS_BOUNDARY(buf, boundary, boundary_len))) { -#ifndef G_OS_WIN32 - if (uncanonicalize) + if (normalize_lbreak) { +#ifdef G_OS_WIN32 + strretchomp(buf); + fputs(buf, outfp); + fputs("\r\n", outfp); +#else strcrchomp(buf); + fputs(buf, outfp); #endif - fputs(buf, outfp); + } else + fputs(buf, outfp); } } |