geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r398618 - in /geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet: InternetHeaders.java MimeBodyPart.java MimeMessage.java MimeMultipart.java
Date Mon, 01 May 2006 15:18:59 GMT
Author: rickmcguire
Date: Mon May  1 08:18:57 2006
New Revision: 398618

URL: http://svn.apache.org/viewcvs?rev=398618&view=rev
Log:
GERONIMO-1956 

There are multiple problems with the MimeMessage.writeTo() method when used to write MultiPart
message data to an output stream.

1) The intenret headers are missing a space between the ":" delimiter and the header data.
2) The filtering version of MimeMessage.writeTo() is not properly processing the header ignore
list.
3) The setDataHandler() method of MimeMessage and MimeBodyPart are not clearing existing Content-Type
and Content-Transfer-Encoding headers.
4) The MimeMessage and MimeBodyPart classes are not setting a default Content-TransferEncoding
header when saveChanges() is called.
5) Remove header improperly gives a NullPointerException when removing a non-existent header.



Modified:
    geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java
    geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeBodyPart.java
    geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java
    geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMultipart.java

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java?rev=398618&r1=398617&r2=398618&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java
(original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/InternetHeaders.java
Mon May  1 08:18:57 2006
@@ -264,7 +264,10 @@
      */
     public void removeHeader(String name) {
         List list = getHeaderList(name);
-        list.clear();
+        // it's possible we might not have the named header.  This is a nop if the header
doesn't exist.
+        if (list != null) {
+            list.clear();
+        }
     }
 
     /**
@@ -402,7 +405,11 @@
     void writeTo(OutputStream out, String[] ignore) throws IOException {
         Map map = new LinkedHashMap(headers);
         if (ignore != null) {
-            map.keySet().removeAll(Arrays.asList(ignore));
+            // remove each of these from the header list (note, they are stored as lower
case keys).
+            for (int i = 0; i < ignore.length; i++) {
+                String key = ignore[i].toLowerCase();
+                map.remove(key);
+            }
         }
         for (Iterator i = map.entrySet().iterator(); i.hasNext();) {
             Map.Entry entry = (Map.Entry) i.next();
@@ -413,6 +420,7 @@
                     InternetHeader header = (InternetHeader) headers.get(j);
                     out.write(header.getName().getBytes());
                     out.write(':');
+                    out.write(' ');
                     out.write(header.getValue().getBytes());
                     out.write(13);
                     out.write(10);

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeBodyPart.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeBodyPart.java?rev=398618&r1=398617&r2=398618&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeBodyPart.java
(original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeBodyPart.java
Mon May  1 08:18:57 2006
@@ -18,21 +18,23 @@
 package javax.mail.internet;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.UnsupportedEncodingException;
 import java.util.Enumeration;
+
 import javax.activation.DataHandler;
 import javax.mail.BodyPart;
 import javax.mail.MessagingException;
 import javax.mail.Multipart;
 import javax.mail.Part;
 import javax.mail.internet.HeaderTokenizer.Token;
+import javax.swing.text.AbstractDocument.Content;
 
-import org.apache.geronimo.mail.util.SessionUtil;
 import org.apache.geronimo.mail.util.ASCIIUtil;
+import org.apache.geronimo.mail.util.SessionUtil;
 
 /**
  * @version $Rev$ $Date$
@@ -374,6 +376,12 @@
 
     public void setDataHandler(DataHandler handler) throws MessagingException {
         dh = handler;
+        // if we have a handler override, then we need to invalidate any content
+        // headers that define the types.  This information will be derived from the
+        // data heander unless subsequently overridden.
+        removeHeader("Content-Type");
+        removeHeader("Content-Transfer-Encoding");
+
     }
 
     public void setContent(Object content, String type) throws MessagingException {
@@ -502,7 +510,7 @@
             else if (!content.match("message/rfc822")) {
                 // simple part, we need to update the header type information
                 // if no encoding is set yet, figure this out from the data handler.
-                if (getHeader("Content-Transfer-Encoding") == null) {
+                if (getSingleHeader("Content-Transfer-Encoding") == null) {
                     setHeader("Content-Transfer-Encoding", MimeUtility.getEncoding(handler));
                 }
 

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java?rev=398618&r1=398617&r2=398618&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java
(original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMessage.java
Mon May  1 08:18:57 2006
@@ -915,6 +915,11 @@
 
     public void setDataHandler(DataHandler handler) throws MessagingException {
         dh = handler;
+        // if we have a handler override, then we need to invalidate any content
+        // headers that define the types.  This information will be derived from the
+        // data heander unless subsequently overridden.
+        removeHeader("Content-Type");
+        removeHeader("Content-Transfer-Encoding");
     }
 
     public void setContent(Object content, String type) throws MessagingException {
@@ -1338,7 +1343,7 @@
             else if (!content.match("message/rfc822")) {
                 // simple part, we need to update the header type information
                 // if no encoding is set yet, figure this out from the data handler content.
-                if (getHeader("Content-Transfer-Encoding") == null) {
+                if (getSingleHeader("Content-Transfer-Encoding") == null) {
                     setHeader("Content-Transfer-Encoding", MimeUtility.getEncoding(handler));
                 }
 

Modified: geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMultipart.java
URL: http://svn.apache.org/viewcvs/geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMultipart.java?rev=398618&r1=398617&r2=398618&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMultipart.java
(original)
+++ geronimo/specs/trunk/geronimo-spec-javamail/src/main/java/javax/mail/internet/MimeMultipart.java
Mon May  1 08:18:57 2006
@@ -212,7 +212,7 @@
             i = part++;
         }
         StringBuffer buf = new StringBuffer(64);
-        buf.append("----=_Part_").append(i).append('.').append(System.currentTimeMillis());
+        buf.append("----=_Part_").append(i).append('_').append((new Object()).hashCode()).append('.').append(System.currentTimeMillis());
         return buf.toString();
     }
 



Mime
View raw message