Bug 38814 - CGIServlet applies wrong charset
CGIServlet applies wrong charset
Product: Tomcat 5
Classification: Unclassified
Component: Servlets:CGI
PC Windows XP
: P1 major (vote)
: ---
Assigned To: Tomcat Developers Mailing List
: PatchAvailable
Depends on:
  Show dependency tree
Reported: 2006-03-01 09:32 UTC by Motoyoshi Sugiu
Modified: 2007-11-29 04:11 UTC (History)
0 users

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

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.