[evolution-data-server] Bug 591811 - Do not re-encode attachments and change CRLF/LF



commit 74b7a0ae62e45df82313a1daaa9064b20f8142bd
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jun 2 19:39:25 2014 +0200

    Bug 591811 - Do not re-encode attachments and change CRLF/LF

 camel/camel-data-wrapper.c |    8 --------
 camel/camel-mime-message.c |   16 ++++++++++++++++
 camel/camel-mime-part.c    |   30 ------------------------------
 3 files changed, 16 insertions(+), 38 deletions(-)
---
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index bf59d5c..826772c 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -195,14 +195,6 @@ data_wrapper_decode_to_stream_sync (CamelDataWrapper *data_wrapper,
                break;
        }
 
-       if (!(camel_content_type_is (data_wrapper->mime_type, "text", "pdf")) && camel_content_type_is 
(data_wrapper->mime_type, "text", "*")) {
-               filter = camel_mime_filter_crlf_new (
-                       CAMEL_MIME_FILTER_CRLF_DECODE,
-                       CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
-               camel_stream_filter_add (CAMEL_STREAM_FILTER (fstream), filter);
-               g_object_unref (filter);
-       }
-
        ret = camel_data_wrapper_write_to_stream_sync (
                data_wrapper, fstream, cancellable, error);
 
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index 447a32f..20f17b0 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -898,6 +898,18 @@ camel_mime_message_has_8bit_parts (CamelMimeMessage *msg)
        return has8bit;
 }
 
+static gboolean
+mime_part_is_attachment (CamelMimePart *mp)
+{
+       const CamelContentDisposition *content_disposition;
+
+       content_disposition = camel_mime_part_get_content_disposition (mp);
+
+       return content_disposition &&
+              content_disposition->disposition &&
+              g_ascii_strcasecmp (content_disposition->disposition, "attachment") == 0;
+}
+
 /* finds the best charset and transfer encoding for a given part */
 static CamelTransferEncoding
 find_best_encoding (CamelMimePart *part,
@@ -1045,6 +1057,10 @@ best_encoding (CamelMimeMessage *msg,
        CamelDataWrapper *wrapper;
        gchar *charset;
 
+       /* Keep attachments untouched. */
+       if (mime_part_is_attachment (part))
+               return TRUE;
+
        wrapper = camel_medium_get_content (CAMEL_MEDIUM (part));
        if (!wrapper)
                return FALSE;
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index bafa449..c7c2b6a 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -683,17 +683,6 @@ mime_part_write_to_stream_sync (CamelDataWrapper *dw,
                                g_object_unref (charenc);
                        }
 
-                       /* we only re-do crlf on encoded blocks */
-                       if (filter && camel_content_type_is (dw->mime_type, "text", "*")) {
-                               CamelMimeFilter *crlf = camel_mime_filter_crlf_new (
-                                       CAMEL_MIME_FILTER_CRLF_ENCODE,
-                                       CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
-
-                               camel_stream_filter_add (
-                                       CAMEL_STREAM_FILTER (filter_stream), crlf);
-                               g_object_unref (crlf);
-                       }
-
                        if (filter) {
                                camel_stream_filter_add (
                                        CAMEL_STREAM_FILTER (filter_stream), filter);
@@ -908,25 +897,6 @@ mime_part_write_to_output_stream_sync (CamelDataWrapper *dw,
                        reencode = TRUE;
                }
 
-               if (filter != NULL && content_type_is_text) {
-                       CamelMimeFilter *crlf;
-                       GOutputStream *temp_stream;
-
-                       crlf = camel_mime_filter_crlf_new (
-                               CAMEL_MIME_FILTER_CRLF_ENCODE,
-                               CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
-                       temp_stream = camel_filter_output_stream_new (
-                               filter_stream, crlf);
-                       g_filter_output_stream_set_close_base_stream (
-                               G_FILTER_OUTPUT_STREAM (temp_stream), FALSE);
-                       g_object_unref (crlf);
-
-                       g_object_unref (filter_stream);
-                       filter_stream = temp_stream;
-
-                       reencode = TRUE;
-               }
-
                if (filter != NULL) {
                        GOutputStream *temp_stream;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]