luehe       2004/07/28 13:42:55

  Modified:    catalina/src/share/org/apache/catalina/connector
                        Response.java
  Log:
  New attempt at fixing Bugtraq 6152759 ("Default charset not included
  in Content-Type response header if no char encoding was specified"),
  as suggested by Bill Barker.
  
  This also fixes a spec non-compliance issue in that ServletResponse.getWriter()
  must update, which it hasn't, the char encoding to ISO-8859-1 if the
  response's character encoding has not been specified as described in
  <code>getCharacterEncoding</code> (i.e., the method just returns the default
  value ISO-8859-1), with the effect that a subsequent call to getContentType()
  will include a charset=ISO-8859-1 component which will also be reflected in
  the Content-Type response header, thereby satisfying the Servlet spec
  requirement that containers must communicate the character encoding used for
  the servlet response's writer to the client.
  
  Revision  Changes    Path
  1.6       +15 -1     
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Response.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Response.java     28 Jul 2004 18:51:10 -0000      1.5
  +++ Response.java     28 Jul 2004 20:42:55 -0000      1.6
  @@ -596,6 +596,20 @@
               throw new IllegalStateException
                   (sm.getString("coyoteResponse.getWriter.ise"));
   
  +        /*
  +         * If the response's character encoding has not been specified as
  +         * described in <code>getCharacterEncoding</code> (i.e., the method
  +         * just returns the default value <code>ISO-8859-1</code>),
  +         * <code>getWriter</code> updates it to <code>ISO-8859-1</code>
  +         * (with the effect that a subsequent call to getContentType() will
  +         * include a charset=ISO-8859-1 component which will also be
  +         * reflected in the Content-Type response header, thereby satisfying
  +         * the Servlet spec requirement that containers must communicate the
  +         * character encoding used for the servlet response's writer to the
  +         * client).
  +         */
  +        setCharacterEncoding(getCharacterEncoding());
  +
           usingWriter = true;
           outputBuffer.checkConverter();
           if (writer == null) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to