Bug 38814 - CGIServlet applies wrong charset
Summary: CGIServlet applies wrong charset
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Servlets:CGI (show other bugs)
Version: 5.5.17
Hardware: PC Windows XP
: P1 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2006-03-01 09:32 UTC by Motoyoshi Sugiu
Modified: 2007-11-29 04:11 UTC (History)
0 users



Attachments
A revised CGIServlet based on Tomcat 5.5.15 source. (76.21 KB, text/plain)
2006-03-01 09:35 UTC, Motoyoshi Sugiu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Motoyoshi Sugiu 2006-03-01 09:32:18 UTC
Suppose the CGI header contains:

   content-type: text/plain; charset=shift_jis

This content type is exactly set to the header of the servlet response. However,
both the reader of the CGI output and the writer of the servlet output always
apply the platform's default character encoding, since InputStreamReader and
OutputStreamWriter are constructed without charset.

I've already written the patch. Please contact me by email, then I can send you
the revised CGIServlet (the source came from 5.5.15).
Comment 1 Motoyoshi Sugiu 2006-03-01 09:35:29 UTC
Created attachment 17811 [details]
A revised CGIServlet based on Tomcat 5.5.15 source.
Comment 2 Motoyoshi Sugiu 2006-03-01 09:44:30 UTC
The revised code was attached. In order to solve this problem, the following
steps are made.

(1) charset is extracted from the content-type in CGI header.

(2) servletContainerStdout is created for the specified charset if any.

(3) commandsStdOut is created for the specified charset if any.
Comment 3 Mark Thomas 2006-03-06 17:49:40 UTC
Fixed using an alternative patch that removed the Stream -> Reader -> Stream
conversions that were causing the problem.