bug in MimeTypeParameterList

Archit Shah <[email protected]> Mon, 24 Apr 2006 20:00:16 -0400
Newsgroups gmane.comp.java.classpath.extensions.discuss
Message-ID <[email protected]>
MimeType's toString doesn't insert the ';' separator before the 
parameter list. Apache SOAP 2.3.1 relies on the toString method of 
MimeType and MimeTypeParameterList for correct behavior and does not 
work with the current classpathx jaf release.

This test case shows the bug in action:

public class Test {
     public static void main(String[] args) throws Exception {
         System.out.println(new javax.activation.MimeType("text/xml; 
charset=utf8"));
     }
}

The following patch fixes the bug by forcing a non-empty 
MimeTypeParameterList to start with ';' as indicated by the grammar in 
RFC2045.

diff -u -r1.6 MimeTypeParameterList.java
--- source/javax/activation/MimeTypeParameterList.java  25 Aug 2005
+++ source/javax/activation/MimeTypeParameterList.java  24 Apr 2006
@@ -231,11 +231,8 @@
          String name = (String)i.next();
          String value = (String)parameterValues.get(name.toLowerCase());

-        if (buffer.length() > 0)
-          {
-            buffer.append(';');
-            buffer.append(' ');
-          }
+        buffer.append(';');
+        buffer.append(' ');
          buffer.append(name);
          buffer.append('=');
          buffer.append(quote(value));

  -- Archit