Discussion:
what javamail expects in param list?
Oleg Sukhodolsky
2008-12-06 05:55:46 UTC
Permalink
Hi,

I have got exception while parsing the following Content-Disposition:

Content-Disposition: attachment;
filename==?Windows-1251?B?8OXq4ujn6PL7IMjPLmRvYw?=

javamail says:
javax.mail.internet.ParseException: Expected parameter value, got "="
at javax.mail.internet.ParameterList.<init>(ParameterList.java:253)

here is a test for this problem:

import javax.mail.internet.ParameterList;
import javax.mail.internet.ParseException;

public class Crm673 {
public static void main(String[] args) throws ParseException {
String params = "; filename==?Windows-1251?B?8OXq4ujn6PL7IMjPLmRvYw?=";
final ParameterList pl = new ParameterList(params);
System.out.println(pl.get("filename"));
}
}

As far as I understand the code, javamail expects either ATOM or
QUOTEDSTRING after "filename=" but found
"=". So, what kind of quoted string it expect here? Is there any way
to help/force javamail to understand
this file name?

BTW I'm using latest snapshot of 1.4.2

Thanks in advance, Oleg.

===========================================================================
To unsubscribe, send email to ***@java.sun.com and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
***@java.sun.com and include in the body of the message "help".
Bill Shannon
2008-12-06 07:47:53 UTC
Permalink
Post by Oleg Sukhodolsky
Hi,
Content-Disposition: attachment;
filename==?Windows-1251?B?8OXq4ujn6PL7IMjPLmRvYw?=
javax.mail.internet.ParseException: Expected parameter value, got "="
at javax.mail.internet.ParameterList.<init>(ParameterList.java:253)
import javax.mail.internet.ParameterList;
import javax.mail.internet.ParseException;
public class Crm673 {
public static void main(String[] args) throws ParseException {
String params = "; filename==?Windows-1251?B?8OXq4ujn6PL7IMjPLmRvYw?=";
final ParameterList pl = new ParameterList(params);
System.out.println(pl.get("filename"));
}
}
As far as I understand the code, javamail expects either ATOM or
QUOTEDSTRING after "filename=" but found
"=". So, what kind of quoted string it expect here? Is there any way
to help/force javamail to understand
this file name?
Right, that's an illegal header. The software that produced it is broken
and you should report this bug to the owner of that software, if possible.

Try setting the System property "mail.mime.parameters.strict" to "false".
That might allow JavaMail to parse the header. You'll need to decode the
value yourself, using the MimeUtility methods, or set the
"mail.mime.decodefilename" System property to "true".

===========================================================================
To unsubscribe, send email to ***@java.sun.com and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
***@java.sun.com and include in the body of the message "help".
Bill Shannon
2008-12-10 00:09:13 UTC
Permalink
Yes, you're right. Thanks for the example. I updated the JavaMail 1.4.2
snapshot to fix this. Give it a try.
Hi Bill,
thank you for your suggestions. Unfortunately none of these properties helps :(
Anyway now I know that this is a bug in client's mailer and will try
to workaround it.
Thanks, Oleg.
Post by Bill Shannon
Post by Oleg Sukhodolsky
Hi,
Content-Disposition: attachment;
filename==?Windows-1251?B?8OXq4ujn6PL7IMjPLmRvYw?=
javax.mail.internet.ParseException: Expected parameter value, got "="
at javax.mail.internet.ParameterList.<init>(ParameterList.java:253)
import javax.mail.internet.ParameterList;
import javax.mail.internet.ParseException;
public class Crm673 {
public static void main(String[] args) throws ParseException {
String params = ";
filename==?Windows-1251?B?8OXq4ujn6PL7IMjPLmRvYw?=";
final ParameterList pl = new ParameterList(params);
System.out.println(pl.get("filename"));
}
}
As far as I understand the code, javamail expects either ATOM or
QUOTEDSTRING after "filename=" but found
"=". So, what kind of quoted string it expect here? Is there any way
to help/force javamail to understand
this file name?
Right, that's an illegal header. The software that produced it is broken
and you should report this bug to the owner of that software, if possible.
Try setting the System property "mail.mime.parameters.strict" to "false".
That might allow JavaMail to parse the header. You'll need to decode the
value yourself, using the MimeUtility methods, or set the
"mail.mime.decodefilename" System property to "true".
===========================================================================
To unsubscribe, send email to ***@java.sun.com and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
***@java.sun.com and include in the body of the message "help".
Oleg Sukhodolsky
2008-12-10 07:28:16 UTC
Permalink
Thanks a lot. The new snapshot works perfectly :)
Post by Bill Shannon
Yes, you're right. Thanks for the example. I updated the JavaMail 1.4.2
snapshot to fix this. Give it a try.
Hi Bill,
thank you for your suggestions. Unfortunately none of these properties helps :(
Anyway now I know that this is a bug in client's mailer and will try
to workaround it.
Thanks, Oleg.
Post by Bill Shannon
Post by Oleg Sukhodolsky
Hi,
Content-Disposition: attachment;
filename==?Windows-1251?B?8OXq4ujn6PL7IMjPLmRvYw?=
javax.mail.internet.ParseException: Expected parameter value, got "="
at javax.mail.internet.ParameterList.<init>(ParameterList.java:253)
import javax.mail.internet.ParameterList;
import javax.mail.internet.ParseException;
public class Crm673 {
public static void main(String[] args) throws ParseException {
String params = ";
filename==?Windows-1251?B?8OXq4ujn6PL7IMjPLmRvYw?=";
final ParameterList pl = new ParameterList(params);
System.out.println(pl.get("filename"));
}
}
As far as I understand the code, javamail expects either ATOM or
QUOTEDSTRING after "filename=" but found
"=". So, what kind of quoted string it expect here? Is there any way
to help/force javamail to understand
this file name?
Right, that's an illegal header. The software that produced it is broken
and you should report this bug to the owner of that software, if possible.
Try setting the System property "mail.mime.parameters.strict" to "false".
That might allow JavaMail to parse the header. You'll need to decode the
value yourself, using the MimeUtility methods, or set the
"mail.mime.decodefilename" System property to "true".
===========================================================================
To unsubscribe, send email to ***@java.sun.com and include in the body
of the message "signoff JAVAMAIL-INTEREST". For general help, send email to
***@java.sun.com and include in the body of the message "help".
Loading...