gchar *filename;
MimeInfo *mimeinfo;
- filename = procmsg_get_message_file(msginfo);
- if (!filename)
+ filename = procmsg_get_message_file_path(msginfo);
+ if (!filename || !is_file_exist(filename)) {
+ g_free(filename);
+ filename = procmsg_get_message_file(msginfo);
+ }
+ if (!filename || !is_file_exist(filename))
return NULL;
+
if (msginfo->folder->stype != F_QUEUE &&
msginfo->folder->stype != F_DRAFT)
mimeinfo = procmime_scan_file(filename);
if (mimeinfo->type == MIMETYPE_TEXT ||
mimeinfo->type == MIMETYPE_MESSAGE) {
- tmp_file = get_tmp_file();
- if (canonicalize_file(mimeinfo->data.filename, tmp_file) < 0) {
- g_free(tmp_file);
- fclose(infp);
- }
- if ((tmp_fp = fopen(tmp_file, "rb")) == NULL) {
- FILE_OP_ERROR(tmp_file, "fopen");
- unlink(tmp_file);
- g_free(tmp_file);
+ if (mimeinfo->content == MIMECONTENT_FILE) {
+ tmp_file = get_tmp_file();
+ if (canonicalize_file(mimeinfo->data.filename, tmp_file) < 0) {
+ g_free(tmp_file);
+ fclose(infp);
+ return FALSE;
+ }
+ if ((tmp_fp = fopen(tmp_file, "rb")) == NULL) {
+ FILE_OP_ERROR(tmp_file, "fopen");
+ unlink(tmp_file);
+ g_free(tmp_file);
+ fclose(infp);
+ return FALSE;
+ }
+ } else {
+ gchar *out = canonicalize_str(mimeinfo->data.mem);
fclose(infp);
+ tmp_fp = infp = str_open_as_stream(out);
+ g_free(out);
+ if (infp == NULL)
+ return FALSE;
}
}
fclose(tmp_fp);
unlink(tmp_file);
g_free(tmp_file);
- }
+ }
} else if (encoding == ENC_QUOTED_PRINTABLE) {
gchar inbuf[BUFFSIZE], outbuf[BUFFSIZE * 4];
while (fgets(inbuf, sizeof(inbuf), infp) != NULL) {
qp_encode_line(outbuf, inbuf);
- fputs(outbuf, outfp);
+
+ if (!strncmp("From ", outbuf, sizeof("From ")-1)) {
+ gchar *tmpbuf = outbuf;
+
+ tmpbuf += sizeof("From ")-1;
+
+ fputs("=46rom ", outfp);
+ fputs(tmpbuf, outfp);
+ } else
+ fputs(outbuf, outfp);
}
} else {
gchar buf[BUFFSIZE];
{NULL, NULL, FALSE}};
guint content_start, i;
FILE *fp;
+ gchar buf[BUFFSIZE];
gint mime_major, mime_minor;
procmime_decode_content(mimeinfo);
fseek(fp, mimeinfo->offset, SEEK_SET);
procheader_get_header_fields(fp, hentry);
if (hentry[0].body != NULL)
- conv_unmime_header_overwrite(hentry[0].body);
+ conv_unmime_header(buf, sizeof(buf), hentry[0].body,
+ NULL);
if (hentry[2].body != NULL)
- conv_unmime_header_overwrite(hentry[2].body);
+ conv_unmime_header(buf, sizeof(buf), hentry[2].body,
+ NULL);
if (hentry[4].body != NULL)
- conv_unmime_header_overwrite(hentry[4].body);
+ conv_unmime_header(buf, sizeof(buf), hentry[4].body,
+ NULL);
content_start = ftell(fp);
fclose(fp);
MimeInfo *subinfo;
subinfo = procmime_mimeinfo_new();
+ subinfo->content = MIMECONTENT_FILE;
subinfo->encoding_type = ENC_UNKNOWN;
subinfo->type = MIMETYPE_TEXT;
subinfo->subtype = g_strdup("plain");
}
procheader_get_header_fields(fp, hentry);
if (hentry[0].body != NULL)
- conv_unmime_header_overwrite(hentry[0].body);
+ conv_unmime_header(buf, sizeof(buf), hentry[0].body,
+ NULL);
if (hentry[2].body != NULL)
- conv_unmime_header_overwrite(hentry[2].body);
+ conv_unmime_header(buf, sizeof(buf), hentry[2].body,
+ NULL);
if (hentry[4].body != NULL)
- conv_unmime_header_overwrite(hentry[4].body);
+ conv_unmime_header(buf, sizeof(buf), hentry[4].body,
+ NULL);
lastoffset = ftell(fp);
}
}