Author: bago
Date: Tue Mar 7 09:58:13 2006
New Revision: 383945
URL: http://svn.apache.org/viewcvs?rev=383945&view=rev
Log:
Applied patch for JAMES-443 (thanks to Norman Maurer)
Also added a test to AddFooterTest as proof of the issue/patch.
Modified:
james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java
james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java
Modified:
james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java?rev=383945&r1=383944&r2=383945&view=diff
==============================================================================
---
james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java
(original)
+++
james/server/trunk/src/java/org/apache/james/transport/mailets/AddFooter.java
Tue Mar 7 09:58:13 2006
@@ -214,9 +214,11 @@
MimeMultipart multipart = (MimeMultipart)part.getContent();
MimeBodyPart firstPart = (MimeBodyPart)multipart.getBodyPart(0);
boolean isFooterAttached = attachFooter(firstPart);
- //We have to do this because of a bug in JavaMail (ref id 4403733)
- //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4403733
- part.setContent(multipart);
+ if (isFooterAttached) {
+ //We have to do this because of a bug in JavaMail (ref id
4403733)
+ //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4403733
+ part.setContent(multipart);
+ }
return isFooterAttached;
} else if (part.isMimeType("multipart/alternative")) {
MimeMultipart multipart = (MimeMultipart)part.getContent();
@@ -228,9 +230,11 @@
MimeBodyPart mimeBodyPart =
(MimeBodyPart)multipart.getBodyPart(index);
isFooterAttached |= attachFooter(mimeBodyPart);
}
- //We have to do this because of a bug in JavaMail (ref id 4403733)
- //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4403733
- part.setContent(multipart);
+ if (isFooterAttached) {
+ //We have to do this because of a bug in JavaMail (ref id
4403733)
+ //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4403733
+ part.setContent(multipart);
+ }
return isFooterAttached;
} else {
//Give up... we won't attach the footer to this MimePart
Modified:
james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java
URL:
http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java?rev=383945&r1=383944&r2=383945&view=diff
==============================================================================
---
james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java
(original)
+++
james/server/trunk/src/test/org/apache/james/transport/mailets/AddFooterTest.java
Tue Mar 7 09:58:13 2006
@@ -103,6 +103,39 @@
}
/*
+ * Test for JAMES-443
+ * This should not add the header and should leave the multipart/mixed
Content-Type intact
+ */
+ public void testAddFooterMimeNestedUnsupportedMultipart() throws
MessagingException, IOException {
+
+ // quoted printable mimemessage text/plain
+ String asciisource = "MIME-Version: 1.0\r\n"
+ +"Content-Type: multipart/mixed;
boundary=\"===============0204599088==\"\r\n"
+ +"\r\n"
+ +"This is a cryptographically signed message in MIME
format.\r\n"
+ +"\r\n"
+ +"--===============0204599088==\r\n"
+ +"Content-Type: multipart/unsupported;
boundary=\"------------ms050404020900070803030808\"\r\n"
+ +"\r\n"
+ +"--------------ms050404020900070803030808\r\n"
+ +"Content-Type: text/plain; charset=ISO-8859-1\r\n"
+ +"\r\n"
+ +"test\r\n"
+ +"\r\n"
+ +"--------------ms050404020900070803030808--\r\n"
+ +"\r\n"
+ +"--===============0204599088==--\r\n";
+ // String asciisource = "Subject: test\r\nContent-Type:
multipart/mixed; boundary=\"===============0204599088==\"\r\nMIME-Version:
1.0\r\n\r\nThis is a cryptographically signed message in MIME
format.\r\n\r\n--===============0204599088==\r\nContent-Type:
text/plain\r\n\r\ntest\r\n--===============0204599088==\r\nContent-Type:
text/plain; charset=\"us-ascii\"\r\nMIME-Version:
1.0\r\nContent-Transfer-Encoding: 7bit\r\nContent-Disposition:
inline\r\n\r\ntest\r\n--===============0204599088==--\r\n";
+
+ String footer = "------ my footer \u00E0/\u20AC ------";
+
+ String res = processAddFooter(asciisource, footer);
+
+ assertEquals(asciisource, res);
+
+ }
+
+ /*
* Class under test for String getSubject()
*/
public void testAddFooterTextPlainCP1252toISO8859() throws
MessagingException, IOException {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]