tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5 CoyoteResponse.java
Date Wed, 03 Sep 2003 22:10:33 GMT
luehe       2003/09/03 15:10:33

  Modified:    catalina/src/share/org/apache/coyote/tomcat5
                        CoyoteResponse.java
  Log:
  Fixed Bugtraq 4916164 ("Tomcat's default charset for Preferred locale
  overrides page directive")
  
  The HTTP spec mandates that in:
  
            media-type     = type "/" subtype *( ";" parameter )
            parameter      = attribute "=" value
  
  there be no (linear) white space between the type and subtype, nor
  between an attribute and its value, but it does not make any statement
  about the number of spaces surrounding the semicolon.
  
  The HTTP spec itself has this example:
  
    Content-Type: text/html; charset=ISO-8859-4
  
  Revision  Changes    Path
  1.8       +27 -6     jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/CoyoteResponse.java
  
  Index: CoyoteResponse.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/CoyoteResponse.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CoyoteResponse.java	2 Sep 2003 21:21:59 -0000	1.7
  +++ CoyoteResponse.java	3 Sep 2003 22:10:33 -0000	1.8
  @@ -713,9 +713,30 @@
               return;
   
           coyoteResponse.setContentType(type);
  -        if ((type != null) && (type.indexOf(";charset=") != -1)) {
  -            isCharacterEncodingSet = true;
  +
  +        // Check to see if content type contains charset
  +        if (type != null) {
  +            int index = type.indexOf(";");
  +            if (index != -1) {
  +                int len = type.length();
  +                index++;
  +                while (index < len && Character.isSpace(type.charAt(index)))
{
  +                    index++;
  +                }
  +                if (index+7 < len
  +                        && type.charAt(index) == 'c'
  +                        && type.charAt(index+1) == 'h'
  +                        && type.charAt(index+2) == 'a'
  +                        && type.charAt(index+3) == 'r'
  +                        && type.charAt(index+4) == 's'
  +                        && type.charAt(index+5) == 'e'
  +                        && type.charAt(index+6) == 't'
  +                        && type.charAt(index+7) == '=') {
  +                    isCharacterEncodingSet = true;
  +                }
  +            }
           }
  +
           isContentTypeSet = true;    
       }
   
  
  
  

Mime
View raw message