-
1. Re: The filename property of <e:workbook> is not mail-safe
bobyang Oct 8, 2009 4:58 PM (in response to bobyang)And it is a bug of jboss-seam-excel ?
Can I submit is as a bug?Cheers! : )
-
2. Re: The filename property of <e:workbook> is not mail-safe
bobyang Oct 11, 2009 11:58 AM (in response to bobyang)Forget it. It is not a bug. The implementation of the <e:workbook/> filename property is fine.
Because, I found there is no standard way to specify the Content-Disposition header value.
The encode of the content-disposition header value can only be ASCII. If the file name is non-ascii, then there is no portable way to encode it.The Content-Disposition is defined in RFC2183, the header encoding is defined in RFC2047 and RFC2231.
In short, IE does not support RFC2231 but obey the RFC2047 well. While the Firefox does not obey the RFC2047 well but it support RFC2231.
So there is not a portable way to support non-ASCII character encoding of Content-Disposition header value, you have to use different encoding method for different browser.
Especially, there is no way to encode non-ASCII for the Safari.
See this link for detail information.Below is my solution for Firefox and IE.
- Use FacesContext to get User-Agent.
- If the User-Agent contains 'MSIE' then the filename = new String(origFileName.getBytes(”GB18030″), “ISO8859-1″);
- For other case, the filename = MimeUtility.encodeText(origFileName);
Cheers!