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-jasper/jasper2/src/share/org/apache/jasper/compiler Node.java Parser.java ParserController.java Validator.java
Date Wed, 07 May 2003 23:05:26 GMT
luehe       2003/05/07 16:05:25

  Modified:    jasper2/src/share/org/apache/jasper/compiler Node.java
                        Parser.java ParserController.java Validator.java
  Log:
  Fixed Bugtraq 4860040: Jasper *always* passes initial response character encoding to ServletResponse
  
  Revision  Changes    Path
  1.73      +23 -3     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java
  
  Index: Node.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- Node.java	7 May 2003 02:05:58 -0000	1.72
  +++ Node.java	7 May 2003 23:05:24 -0000	1.73
  @@ -396,6 +396,18 @@
   	private String jspConfigPageEnc;
   
   	/*
  +	 * Flag indicating if the default page encoding is being used (only
  +	 * applicable with standard syntax).
  +	 *
  +	 * True if the page does not provide a page directive with a
  +	 * 'contentType' attribute (or the 'contentType' attribute doesn't
  +	 * have a CHARSET value), the page does not provide a page directive
  +	 * with a 'pageEncoding' attribute, and there is no JSP configuration
  +	 * element page-encoding whose URL pattern matches the page.
  +	 */
  +	private boolean isDefaultPageEncoding;
  +
  +	/*
   	 * Indicates whether an encoding has been explicitly specified in the
   	 * page's XML prolog (only used for pages in XML syntax).
   	 * This information is used to decide whether a translation error must
  @@ -451,6 +463,14 @@
   	    return pageEnc;
   	}
   
  +	public void setIsDefaultPageEncoding(boolean isDefault) {
  +	    isDefaultPageEncoding = isDefault;
  +	}
  +
  +	public boolean isDefaultPageEncoding() {
  +	    return isDefaultPageEncoding;
  +	}
  +	
   	public void setIsEncodingSpecifiedInProlog(boolean isSpecified) {
   	    isEncodingSpecifiedInProlog = isSpecified;
   	}
  
  
  
  1.73      +6 -4      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- Parser.java	31 Mar 2003 22:47:27 -0000	1.72
  +++ Parser.java	7 May 2003 23:05:25 -0000	1.73
  @@ -147,7 +147,8 @@
   				   boolean directivesOnly,
   				   JarFile jarFile,
   				   String pageEnc,
  -				   String jspConfigPageEnc)
  +				   String jspConfigPageEnc,
  +				   boolean isDefaultPageEncoding)
   		throws JasperException {
   
   	Parser parser = new Parser(pc, reader, isTagFile, directivesOnly,
  @@ -156,6 +157,7 @@
   	Node.Root root = new Node.Root(reader.mark(), parent, false);
   	root.setPageEncoding(pageEnc);
   	root.setJspConfigPageEncoding(jspConfigPageEnc);
  +	root.setIsDefaultPageEncoding(isDefaultPageEncoding);
   
   	if (directivesOnly) {
   	    parser.parseTagFileDirectives(root);
  
  
  
  1.41      +14 -9     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java
  
  Index: ParserController.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- ParserController.java	26 Apr 2003 01:03:30 -0000	1.40
  +++ ParserController.java	7 May 2003 23:05:25 -0000	1.41
  @@ -105,6 +105,8 @@
   
       private String sourceEnc;
   
  +    private boolean isDefaultPageEncoding;
  +
       /*
        * Constructor
        */
  @@ -187,6 +189,8 @@
   
   	Node.Nodes parsedPage = null;
   	isEncodingSpecifiedInProlog = false;
  +	isDefaultPageEncoding = false;
  +
   	String absFileName = resolveFileName(inFileName);
   	String jspConfigPageEnc = getJspConfigPageEncoding(absFileName);
   
  @@ -246,7 +250,8 @@
   						    err);
                   parsedPage = Parser.parse(this, jspReader, parent, isTagFile,
   					  directivesOnly, jarFile, sourceEnc,
  -					  jspConfigPageEnc);
  +					  jspConfigPageEnc,
  +					  isDefaultPageEncoding);
               } finally {
   		if (inStreamReader != null) {
   		    try {
  @@ -409,13 +414,18 @@
   	sourceEnc = jspConfigPageEnc;
   	if (sourceEnc == null) {
   	    sourceEnc = getPageEncodingForJspSyntax(jspReader, startMark);
  +	    if (sourceEnc == null) {
  +		// Default to "ISO-8859-1" per JSP spec
  +		sourceEnc = "ISO-8859-1";
  +		isDefaultPageEncoding = true;
  +	    }
   	}
  -
  -	return;
       }
       
       /*
  -     * Determines page source encoding for JSP page or tag file in JSP syntax
  +     * Determines page source encoding for page or tag file in JSP syntax
  +     *
  +     * @return The page encoding, or null if not found
        */
       private String getPageEncodingForJspSyntax(JspReader jspReader,
   						 Mark startMark)
  @@ -451,11 +461,6 @@
                           Parser.parseAttributes(this, jspReader));
   		if (encoding != null) break;
   	    }
  -	}
  -
  -	if (encoding == null) {
  -	    // Default to "ISO-8859-1" per JSP spec
  -	    encoding = "ISO-8859-1";
   	}
   
   	return encoding;
  
  
  
  1.106     +7 -5      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java
  
  Index: Validator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v
  retrieving revision 1.105
  retrieving revision 1.106
  diff -u -r1.105 -r1.106
  --- Validator.java	1 May 2003 16:42:12 -0000	1.105
  +++ Validator.java	7 May 2003 23:05:25 -0000	1.106
  @@ -1455,6 +1455,7 @@
   	// Determine the default output content type
   	PageInfo pageInfo = compiler.getPageInfo();
   	String contentType = pageInfo.getContentType();
  +
   	if (contentType == null || contentType.indexOf("charset=") < 0) {
   	    boolean isXml = page.getRoot().isXmlSyntax();
   	    String defaultType;
  @@ -1468,8 +1469,9 @@
   	    if (isXml) {
   		charset = "UTF-8";
   	    } else {
  -		charset = page.getRoot().getPageEncoding();
  -		// The resulting charset might be null
  +		if (!page.getRoot().isDefaultPageEncoding()) {
  +		    charset = page.getRoot().getPageEncoding();
  +		}
   	    }
   
   	    if (charset != null) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message