Index: camel/providers/local/camel-mbox-folder.c
===================================================================
--- camel/providers/local/camel-mbox-folder.c	(revision 7772)
+++ camel/providers/local/camel-mbox-folder.c	(working copy)
@@ -238,7 +238,7 @@
 
 	/* and write the content to the filtering stream, that translates '\nFrom' into '\n>From' */
 	filter_stream = (CamelStream *) camel_stream_filter_new_with_stream(output_stream);
-	filter_from = (CamelMimeFilter *) camel_mime_filter_from_new();
+	filter_from = (CamelMimeFilter *) camel_mime_filter_from_new( CAMEL_MIME_FILTER_FROM_ENCODE );
 	camel_stream_filter_add((CamelStreamFilter *) filter_stream, filter_from);
 	if (camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, filter_stream) == -1
 	    || camel_stream_write(filter_stream, "\n", 1) == -1
@@ -328,6 +328,7 @@
 	int fd, retval;
 	int retried = FALSE;
 	off_t frompos;
+	CamelMimeFilter *filter_from = NULL;
 
 	d(printf("Getting message %s\n", uid));
 
@@ -402,6 +403,10 @@
 		goto fail;
 	}
 	
+
+	filter_from = (CamelMimeFilter *) camel_mime_filter_from_new( CAMEL_MIME_FILTER_FROM_DECODE );
+	camel_mime_parser_filter_add (parser, filter_from);
+
 	message = camel_mime_message_new();
 	if (camel_mime_part_construct_from_parser((CamelMimePart *)message, parser) == -1) {
 		camel_exception_setv(ex, errno==EINTR?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM,
@@ -419,7 +424,10 @@
 
 	if (parser)
 		camel_object_unref((CamelObject *)parser);
-	
+
+	if (filter_from)
+		camel_object_unref((CamelObject *)filter_from);
+
 	/* use the opportunity to notify of changes (particularly if we had a rebuild) */
 	if (camel_folder_change_info_changed(lf->changes)) {
 		camel_object_trigger_event((CamelObject *)folder, "folder_changed", lf->changes);
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 7772)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,19 @@
+2007-05-22  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #245683
+	
+	* camel-mime-filter-from.h (camel_mime_filter_from_new):
+	* camel-mime-filter-from.c (camel_mime_filter_from_new, filter):
+	Added support for encoding and decoding future, new enum
+	CamelMimeFilterFromDirection.
+	
+	* camel-movemail.c (camel_movemail_solaris):
+	* providers/local/camel-mbox-folder.c (mbox_append_message):
+	Added parameter for encode into call of camel_mime_filter_from_new
+	
+	* providers/local/camel-mbox-folder.c (mbox_get_message):
+	Added CamelMimeFilterFrom into parse when reading mail content
+
 2007-05-16  Jules Colding  <colding@omesc.com>
 
 	* camel-lock.c (camel_lock_dot): Use g_mkstemp()
Index: camel/camel-movemail.c
===================================================================
--- camel/camel-movemail.c	(revision 7772)
+++ camel/camel-movemail.c	(working copy)
@@ -470,7 +470,7 @@
 	camel_mime_parser_scan_from(mp, TRUE);
 	camel_mime_parser_init_with_fd(mp, sfd);
 
-	ffrom = camel_mime_filter_from_new();
+	ffrom = camel_mime_filter_from_new( CAMEL_MIME_FILTER_FROM_ENCODE );
 
 	while (camel_mime_parser_step(mp, &buffer, &len) == CAMEL_MIME_PARSER_STATE_FROM) {
 		g_assert(camel_mime_parser_from_line(mp));
Index: camel/camel-mime-filter-from.c
===================================================================
--- camel/camel-mime-filter-from.c	(revision 7772)
+++ camel/camel-mime-filter-from.c	(working copy)
@@ -103,16 +103,34 @@
 						break;
 					}
 				} else {
+					char *gt = NULL;
+
+					if ( *inptr == '>'){
+						gt = inptr;
+						while (inptr < inend && *inptr == '>')
+							inptr++;
+					}
 					if (!strncmp(inptr, "From ", 5)) {
-						fromcount++;
-						/* yes, we do alloc them on the stack ... at most we're going to get
-						   len / 7 of them anyway */
-						node = alloca(sizeof(*node));
-						node->pointer = inptr;
-						node->next = NULL;
-						tail->next = node;
-						tail = node;
-						inptr += 5;
+						if (f->direction == CAMEL_MIME_FILTER_FROM_ENCODE){
+							fromcount++;
+							/* yes, we do alloc them on the stack ... at most we're going to get
+							   len / 7 of them anyway */
+							node = alloca(sizeof(*node));
+							node->pointer = inptr;
+							node->next = NULL;
+							tail->next = node;
+							tail = node;
+							inptr += 5;
+						}else if (gt) { /* && f->direction == CAMEL_MIME_FILTER_FROM_DECODE */
+							/* we need at least one '>' character */
+							fromcount++;
+							node = alloca(sizeof(*node));
+							node->pointer = gt;
+							node->next = NULL;
+							tail->next = node;
+							tail = node;
+							inptr += 5;
+						}
 					}
 				}
 			} else {
@@ -125,16 +143,29 @@
 	f->midline = midline;
 
 	if (fromcount > 0) {
-		camel_mime_filter_set_size(mf, len + fromcount, FALSE);
-		node = head;
-		inptr = in;
-		outptr = mf->outbuf;
-		while (node) {
-			memcpy(outptr, inptr, node->pointer - inptr);
-			outptr += node->pointer - inptr;
-			*outptr++ = '>';
-			inptr = node->pointer;
-			node = node->next;
+		if (f->direction == CAMEL_MIME_FILTER_FROM_ENCODE){
+			camel_mime_filter_set_size(mf, len + fromcount, FALSE);
+			node = head;
+			inptr = in;
+			outptr = mf->outbuf;
+			while (node) {
+				memcpy(outptr, inptr, node->pointer - inptr);
+				outptr += node->pointer - inptr;
+				*outptr++ = '>';
+				inptr = node->pointer;
+				node = node->next;
+			}
+		}else{ /* f->direction == CAMEL_MIME_FILTER_FROM_DECODE */
+			camel_mime_filter_set_size(mf, len - fromcount, FALSE);
+			node = head;
+			inptr = in;
+			outptr = mf->outbuf;
+			while (node) {
+				memcpy(outptr, inptr, node->pointer - inptr);
+				outptr += node->pointer - inptr;
+				inptr = node->pointer + 1;
+				node = node->next;
+			}
 		}
 		memcpy(outptr, inptr, inend - inptr);
 		outptr += inend - inptr;
@@ -172,15 +203,19 @@
 
 /**
  * camel_mime_filter_from_new:
+ * @direction: encode vs decode
  *
  * Create a new #CamelMimeFilterFrom object.
  * 
  * Returns a new #CamelMimeFilterFrom object
  **/
 CamelMimeFilterFrom *
-camel_mime_filter_from_new (void)
+camel_mime_filter_from_new (CamelMimeFilterFromDirection direction)
 {
 	CamelMimeFilterFrom *new = CAMEL_MIME_FILTER_FROM ( camel_object_new (camel_mime_filter_from_get_type ()));
+
+	new->direction = direction;
+
 	return new;
 }
 
@@ -197,7 +232,7 @@
 	g_tk_init(&argc, &argv);
 
 
-	f = camel_mime_filter_from_new();
+	f = camel_mime_filter_from_new( CAMEL_MIME_FILTER_FROM_ENCODE );
 
 	buffer = "This is a test\nFrom Someone\nTo someone. From Someone else, From\n From blah\nFromblah\nBye! \nFrom ";
 	len = strlen(buffer);
Index: camel/camel-mime-filter-from.h
===================================================================
--- camel/camel-mime-filter-from.h	(revision 7772)
+++ camel/camel-mime-filter-from.h	(working copy)
@@ -34,9 +34,15 @@
 typedef struct _CamelMimeFilterFrom      CamelMimeFilterFrom;
 typedef struct _CamelMimeFilterFromClass CamelMimeFilterFromClass;
 
+typedef enum {
+	CAMEL_MIME_FILTER_FROM_ENCODE,
+	CAMEL_MIME_FILTER_FROM_DECODE
+} CamelMimeFilterFromDirection;
+
 struct _CamelMimeFilterFrom {
 	CamelMimeFilter parent;
 	
+	CamelMimeFilterFromDirection direction;
 	int midline;		/* are we between lines? */
 };
 
@@ -45,7 +51,7 @@
 };
 
 CamelType		camel_mime_filter_from_get_type	(void);
-CamelMimeFilterFrom      *camel_mime_filter_from_new	(void);
+CamelMimeFilterFrom      *camel_mime_filter_from_new	(CamelMimeFilterFromDirection direction);
 
 G_END_DECLS
 
