[Libpst-commits] r60 - trunk
Joseph Nahmias
jello at alioth.debian.org
Fri Dec 8 00:33:32 CET 2006
Author: jello
Date: 2006-12-08 00:33:31 +0100 (Fri, 08 Dec 2006)
New Revision: 60
Modified:
trunk/readpst.c
Log:
main(): make sure temp is freed when done with it.
main(): try using the DOS 8.3 filename for the attachment
the long filename is not available, closes tracker patch #303586.
Modified: trunk/readpst.c
===================================================================
--- trunk/readpst.c 2006-12-07 16:51:24 UTC (rev 59)
+++ trunk/readpst.c 2006-12-07 23:33:31 UTC (rev 60)
@@ -147,6 +147,7 @@
char *boundary = NULL, *b1, *b2; // the boundary marker between multipart sections
char *temp = NULL; //temporary char pointer
int attach_num = 0;
+ char *attach_filename = NULL;
int skip_child = 0;
struct file_ll *f, *head;
prog_name = argv[0];
@@ -832,18 +833,27 @@
}
if (mode == MODE_SEPERATE) {
f->name = check_filename(f->name);
- if (item->current_attach->filename2 == NULL) {
+ // If there is a long filename (filename2) use that, otherwise
+ // use the 8.3 filename (filename1)
+ if (item->current_attach->filename2) {
+ attach_filename = item->current_attach->filename2;
+ } else {
+ attach_filename = item->current_attach->filename1;
+ }
+ if (attach_filename == NULL) {
+ // generate our own (dummy) filename for the attachement
temp = xmalloc(strlen(f->name)+15);
sprintf(temp, "%s-attach%i", f->name, attach_num);
} else {
- temp = xmalloc(strlen(f->name)+strlen(item->current_attach->filename2)+15);
+ // have an attachment name, make sure it's unique
+ temp = xmalloc(strlen(f->name)+strlen(attach_filename)+15);
fp = NULL; x=0;
do {
if (fp != NULL) fclose(fp);
if (x == 0)
- sprintf(temp, "%s-%s", f->name, item->current_attach->filename2);
+ sprintf(temp, "%s-%s", f->name, attach_filename);
else
- sprintf(temp, "%s-%s-%i", f->name, item->current_attach->filename2, x);
+ sprintf(temp, "%s-%s-%i", f->name, attach_filename, x);
} while ((fp = fopen(temp, "r"))!=NULL && ++x < 99999999);
if (x > 99999999) {
DIE(("error finding attachment name. exhausted possibilities to %s\n", temp));
@@ -860,6 +870,7 @@
}
fclose(fp);
}
+ if (temp) free(temp); temp = NULL;
} else {
DEBUG_MAIN(("main: Attachment Size is %i\n", item->current_attach->size));
DEBUG_MAIN(("main: Attachment Pointer is %p\n", item->current_attach->data));
@@ -878,11 +889,18 @@
fprintf(f->output, "Content-type: %s\n", item->current_attach->mimetype);
}
fprintf(f->output, "Content-transfer-encoding: base64\n");
- if (item->current_attach->filename2 == NULL) {
+ // If there is a long filename (filename2) use that, otherwise
+ // use the 8.3 filename (filename1)
+ if (item->current_attach->filename2) {
+ attach_filename = item->current_attach->filename2;
+ } else {
+ attach_filename = item->current_attach->filename1;
+ }
+ if (attach_filename == NULL) {
fprintf(f->output, "Content-Disposition: inline\n\n");
} else {
fprintf(f->output, "Content-Disposition: attachment; filename=\"%s\"\n\n",
- item->current_attach->filename2);
+ attach_filename);
}
}
if (item->current_attach->data != NULL) {
More information about the Libpst-commits
mailing list