Dannhauer, Frank
2009-04-23 10:53:32 UTC
javax.mail.internet.MimeUtility.getEncoding() returns either "7bit" or "base64", but never "quoted-printable"
To reproduce:
####################################
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import javax.activation.DataSource;
import javax.mail.internet.MimeUtility;
public class Main {
public static void main(String[] args) throws Exception {
final Charset c = Charset.forName("ISO-8859-15");
final byte[] b = "aaaaƤ".getBytes(c);
System.out.println(MimeUtility.getEncoding(
new DataSource(){
public String getContentType() {
return "text/plain; charset="+MimeUtility.mimeCharset(c.name());
}
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(b);
}
public String getName() {
return null;
}
public OutputStream getOutputStream() throws IOException {
return null;
}
}
));
}
}
####################################
Suggested patch:
Index: source/javax/mail/internet/MimeUtility.java
===================================================================
RCS file: /sources/classpathx/mail/source/javax/mail/internet/MimeUtility.java,v
retrieving revision 1.23
diff -u -r1.23 MimeUtility.java
--- source/javax/mail/internet/MimeUtility.java 27 Nov 2007 22:03:59 -0000 1.23
+++ source/javax/mail/internet/MimeUtility.java 23 Apr 2009 10:18:22 -0000
@@ -1030,7 +1030,7 @@
}
else
{
- if (text)
+ if (!text)
{
return MINORITY_ASCII;
}
####################################
Kind Regards,
Frank
To reproduce:
####################################
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import javax.activation.DataSource;
import javax.mail.internet.MimeUtility;
public class Main {
public static void main(String[] args) throws Exception {
final Charset c = Charset.forName("ISO-8859-15");
final byte[] b = "aaaaƤ".getBytes(c);
System.out.println(MimeUtility.getEncoding(
new DataSource(){
public String getContentType() {
return "text/plain; charset="+MimeUtility.mimeCharset(c.name());
}
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(b);
}
public String getName() {
return null;
}
public OutputStream getOutputStream() throws IOException {
return null;
}
}
));
}
}
####################################
Suggested patch:
Index: source/javax/mail/internet/MimeUtility.java
===================================================================
RCS file: /sources/classpathx/mail/source/javax/mail/internet/MimeUtility.java,v
retrieving revision 1.23
diff -u -r1.23 MimeUtility.java
--- source/javax/mail/internet/MimeUtility.java 27 Nov 2007 22:03:59 -0000 1.23
+++ source/javax/mail/internet/MimeUtility.java 23 Apr 2009 10:18:22 -0000
@@ -1030,7 +1030,7 @@
}
else
{
- if (text)
+ if (!text)
{
return MINORITY_ASCII;
}
####################################
Kind Regards,
Frank