diff src/lib-storage/index/maildir/maildir-mail.c @ 4450:14b10f7ea70e HEAD

Don't break if mailbox path contains ':' characters.
author Timo Sirainen <tss@iki.fi>
date Wed, 28 Jun 2006 01:51:47 +0300
parents f1888ce91702
children fce5140fbe0b
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-mail.c	Wed Jun 28 01:20:32 2006 +0300
+++ b/src/lib-storage/index/maildir/maildir-mail.c	Wed Jun 28 01:51:47 2006 +0300
@@ -121,7 +121,7 @@
 	struct index_mail *mail = (struct index_mail *)_mail;
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
 	struct index_mail_data *data = &mail->data;
-	const char *fname;
+	const char *path, *fname;
 	uoff_t virtual_size;
         enum maildir_uidlist_rec_flag flags;
 
@@ -142,8 +142,10 @@
 			return (uoff_t)-1;
 		}
 	} else {
-		fname = maildir_save_file_get_path(_mail->transaction,
-						   _mail->seq);
+		path = maildir_save_file_get_path(_mail->transaction,
+						  _mail->seq);
+		fname = strrchr(path, '/');
+		fname = fname != NULL ? fname + 1 : path;
 	}
 
 	/* size can be included in filename */
@@ -163,7 +165,7 @@
 	struct index_mail *mail = (struct index_mail *)_mail;
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
 	enum maildir_uidlist_rec_flag flags;
-	const char *fname, *end;
+	const char *path, *fname, *end;
 
 	if (field == MAIL_FETCH_UIDL_FILE_NAME) {
 		if (_mail->uid != 0) {
@@ -174,8 +176,10 @@
 				return NULL;
 			}
 		} else {
-			fname = maildir_save_file_get_path(_mail->transaction,
-							   _mail->seq);
+			path = maildir_save_file_get_path(_mail->transaction,
+							  _mail->seq);
+			fname = strrchr(path, '/');
+			fname = fname != NULL ? fname + 1 : path;
 		}
 		end = strchr(fname, MAILDIR_INFO_SEP);
 		return end == NULL ? fname : t_strdup_until(fname, end);
@@ -190,7 +194,7 @@
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
 	struct index_mail_data *data = &mail->data;
 	struct stat st;
-	const char *fname;
+	const char *path, *fname;
 	uoff_t size;
 	enum maildir_uidlist_rec_flag flags;
 
@@ -206,8 +210,10 @@
 			return (uoff_t)-1;
 		}
 	} else {
-		fname = maildir_save_file_get_path(_mail->transaction,
-						   _mail->seq);
+		path = maildir_save_file_get_path(_mail->transaction,
+						  _mail->seq);
+		fname = strrchr(path, '/');
+		fname = fname != NULL ? fname + 1 : path;
 	}
 
 	/* size can be included in filename */