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



commit fcb8805d3f5285f3da230527567d0e55a3228fe3
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 d66b8c3..529179f 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -196,14 +196,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 eaac94a..687f78c 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -899,6 +899,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,
@@ -1046,6 +1058,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 088584c..b1ecdab 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -684,17 +684,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]