Bug 24380 - Tomcat cannot support file download with non-ISO characters filename
Summary: Tomcat cannot support file download with non-ISO characters filename
Status: RESOLVED DUPLICATE of bug 27796
Alias: None
Product: Tomcat Connectors
Classification: Unclassified
Component: Common (show other bugs)
Version: unspecified
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-04 11:17 UTC by Kenneth Kwan
Modified: 2008-10-05 03:08 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Kwan 2003-11-04 11:17:05 UTC
The problem seems is a header encoding proglem. Tomcat 4.1.29 always return 
headers encoded in UTF8 irrespective of content type and any other settings. 
This casued browser(MSIE) cannot download file with correct non-ISO characters 
filename. There is no such problem found in 4.0.6 which outputs the filename in 
headers with ISO encoding.

Have tried charset=Big5, ISO8859-1, ..., all failed.

Example:

// filename obtained from file system in ISO format and convert to correct xxx 
encoding
filename=new String(filename.getBytes("ISO8859-1"), "xxx");
response.setContentType("application/x-download;charset=xxx"); 
response.setHeader("Content-Disposition", "filename="+filename);
ServletOutputStream out = response.getOutputStream();
// ... read the file from disk and write to user
out.close();
Comment 1 Remy Maucherat 2003-11-04 14:36:16 UTC
There's nothing in any spec which states the encoding that must be used for
headers. content-type specifies the entity body encoding only.
Comment 2 Kenneth Kwan 2003-11-05 01:50:49 UTC
This spec grey area caused Tomcat cannot support non-ISO filename file download 
since 4.1.2x. I think it needs to define clearly somewhere or better to leave 
header encoding as ISO8859-1 as in 4.0.x version rather than UTF8 that most 
browsers, e.g. IE, do not understand.
Comment 3 Kenneth Kwan 2003-11-10 08:11:31 UTC
Just further found it is a "bug" in Coyote/JK2 AJP 1.3 connector which comes 
with Tomcat 4.1.2x.

I have tested the old org.apache.ajp.tomcat4.Ajp13Connector with Tocmat 4.1.2x 
and found everything backs to normal, i.e. Headers are encoded in ISO8859-1 
rather than UTF8
Comment 4 william.barker 2003-11-10 09:52:37 UTC
I agree with Remy on this.  However, I'll have to look into why mod_jk is 
encoding headers at all.  It is unlikely to be fixed in mod_jk, but hopefully 
mod_jk2 will support sending bytes in the headers.
Comment 5 Kenneth Kwan 2003-11-14 09:18:24 UTC
After searching the sources, I found that in around line 333 of 
JkCoyoteHandler.java specifies the use of UTF8. Is it the problem area which 
always encode the headers in UTF8?

private void appendHead(org.apache.coyote.Response res)
        throws IOException
    {
        ....
        C2BConverter c2b=(C2BConverter)res.getNote( utfC2bNote );
        if( c2b==null ) {
            c2b=new C2BConverter(  "UTF8" ); <====== the problem line?
            res.setNote( utfC2bNote, c2b );
        }
        ....
Comment 6 Mark Thomas 2004-12-22 21:55:57 UTC

*** This bug has been marked as a duplicate of 27796 ***