geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r670051 - in /geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet: MimeBodyPart.java MimeMessage.java MimeMultipart.java
Date Fri, 20 Jun 2008 20:15:22 GMT
Author: rickmcguire
Date: Fri Jun 20 13:15:22 2008
New Revision: 670051

URL: http://svn.apache.org/viewvc?rev=670051&view=rev
Log:
GERONIMO-4134 boundary attribute for multipart/related content does not have surrounding quotes

Fix for problems unconvered by the James test suite. 


Modified:
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeBodyPart.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMultipart.java

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeBodyPart.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeBodyPart.java?rev=670051&r1=670050&r2=670051&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeBodyPart.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeBodyPart.java
Fri Jun 20 13:15:22 2008
@@ -527,6 +527,9 @@
             String type = dh.getContentType();
             // parse this content type out so we can do matches/compares.
             ContentType content = new ContentType(type);
+            
+            // we might need to reconcile the content type and our explicitly set type
+            String explicitType = getSingleHeader("Content-Type"); 
             // is this a multipart content?
             if (content.match("multipart/*")) {
                 // the content is suppose to be a MimeMultipart.  Ping it to update it's
headers as well.
@@ -545,7 +548,7 @@
                 }
 
                 // is a content type header set?  Check the property to see if we need to
set this.
-                if (getHeader("Content-Type") == null) {
+                if (explicitType == null) {
                     if (SessionUtil.getBooleanProperty(MIME_SETDEFAULTTEXTCHARSET, true))
{
                         // is this a text type?  Figure out the encoding and make sure it
is set.
                         if (content.match("text/*")) {
@@ -563,6 +566,8 @@
                                     // get the global default.
                                     content.setParameter("charset", MimeUtility.getDefaultMIMECharset());
                                 }
+                                // replace the datasource provided type 
+                                type = content.toString(); 
                             }
                         }
                     }
@@ -570,7 +575,7 @@
             }
 
             // if we don't have a content type header, then create one.
-            if (getSingleHeader("Content-Type") == null) {
+            if (explicitType == null) {
                 // get the disposition header, and if it is there, copy the filename parameter
into the
                 // name parameter of the type.
                 String disp = getHeader("Content-Disposition", null);
@@ -582,10 +587,12 @@
                     // copy and rename the parameter, if it exists.
                     if (filename != null) {
                         content.setParameter("name", filename);
+                        // and update the string version 
+                        type = content.toString(); 
                     }
                 }
                 // set the header with the updated content type information.
-                setHeader("Content-Type", content.toString());
+                setHeader("Content-Type", type);
             }
 
         } catch (IOException e) {

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java?rev=670051&r1=670050&r2=670051&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java
Fri Jun 20 13:15:22 2008
@@ -1362,6 +1362,8 @@
         try {
             // figure out the content type.  If not set, we'll need to figure this out.
             String type = dh.getContentType();
+            // we might need to reconcile the content type and our explicitly set type
+            String explicitType = getSingleHeader("Content-Type"); 
             // parse this content type out so we can do matches/compares.
             ContentType content = new ContentType(type);
 
@@ -1383,7 +1385,7 @@
                 }
 
                 // is a content type header set?  Check the property to see if we need to
set this.
-                if (getSingleHeader("Content-Type") == null) {
+                if (explicitType == null) {
                     if (SessionUtil.getBooleanProperty(session, "MIME_MAIL_SETDEFAULTTEXTCHARSET",
true)) {
                         // is this a text type?  Figure out the encoding and make sure it
is set.
                         if (content.match("text/*")) {
@@ -1401,6 +1403,8 @@
                                     // get the global default.
                                     content.setParameter("charset", MimeUtility.getDefaultMIMECharset());
                                 }
+                                // replace the original type string 
+                                type = content.toString(); 
                             }
                         }
                     }
@@ -1408,7 +1412,7 @@
             }
 
             // if we don't have a content type header, then create one.
-            if (getSingleHeader("Content-Type") == null) {
+            if (explicitType == null) {
                 // get the disposition header, and if it is there, copy the filename parameter
into the
                 // name parameter of the type.
                 String disp = getSingleHeader("Content-Disposition");
@@ -1420,10 +1424,13 @@
                     // copy and rename the parameter, if it exists.
                     if (filename != null) {
                         content.setParameter("name", filename);
+                        // set the header with the updated content type information.
+                        type = content.toString();
                     }
                 }
-                // set the header with the updated content type information.
-                setHeader("Content-Type", content.toString());
+                // if no header has been set, then copy our current type string (which may

+                // have been modified above) 
+                setHeader("Content-Type", type); 
             }
 
             // new javamail 1.4 requirement.

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMultipart.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMultipart.java?rev=670051&r1=670050&r2=670051&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMultipart.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMultipart.java
Fri Jun 20 13:15:22 2008
@@ -91,8 +91,12 @@
             super.setMultipartDataSource((MultipartDataSource) dataSource);
             parsed = true;
         } else {
-            type = new ContentType(ds.getContentType());
-            contentType = type.toString();
+            // We keep the original, provided content type string so that we 
+            // don't end up changing quoting/formatting of the header unless 
+            // changes are made to the content type.  James is somewhat dependent 
+            // on that behavior. 
+            contentType = ds.getContentType(); 
+            type = new ContentType(contentType);
             parsed = false;
         }
     }



Mime
View raw message