You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ba...@apache.org on 2008/06/26 18:56:02 UTC

svn commit: r671948 - /james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java

Author: bago
Date: Thu Jun 26 09:56:01 2008
New Revision: 671948

URL: http://svn.apache.org/viewvc?rev=671948&view=rev
Log:
Backporting from trunk this major issue in remote delivery (message corruption).
RemoteDelivery convertTo7Bit() can corrupt message content. (JAMES-846)
Based on a bugreport+patch provided by Rick McGuire

Modified:
    james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java

Modified: james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java?rev=671948&r1=671947&r2=671948&view=diff
==============================================================================
--- james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java (original)
+++ james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java Thu Jun 26 09:56:01 2008
@@ -776,14 +776,17 @@
                 convertTo7Bit((MimePart)parts.getBodyPart(i));
             }
         } else {
-            if (part.isMimeType("text/*")) {
-                part.setHeader("Content-Transfer-Encoding", "quoted-printable");
-                part.addHeader("X-MIME-Autoconverted", "from 8bit to quoted-printable by "+getMailetContext().getServerInfo());
-            } else {
-                // if the part doesn't contain text it will be base64 encoded.
-                part.setHeader("Content-Transfer-Encoding", "base64");
-                part.addHeader("X-MIME-Autoconverted", "from 8bit to base64 by "+getMailetContext().getServerInfo());
-            }
+            // The content may already be in encoded the form (likely with mail created from a
+            // stream).  In that case, just changing the encoding to quoted-printable will mangle 
+            // the result when this is transmitted.  We must first convert the content into its 
+            // native format, set it back, and only THEN set the transfer encoding to force the 
+            // content to be encoded appropriately.
+            
+            // if the part doesn't contain text it will be base64 encoded.
+            String contentTransferEncoding = part.isMimeType("text/*") ? "quoted-printable" : "base64";
+            part.setContent(part.getContent(), part.getContentType()); 
+            part.setHeader("Content-Transfer-Encoding", contentTransferEncoding);
+            part.addHeader("X-MIME-Autoconverted", "from 8bit to "+contentTransferEncoding+" by "+getMailetContext().getServerInfo());
         }
     }
     



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org