You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bi...@apache.org on 2002/02/22 04:16:09 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/jasper/compiler CommandLineCompiler.java JasperMangler.java JspCompiler.java

billbarker    02/02/21 19:16:09

  Modified:    src/share/org/apache/jasper/compiler
                        CommandLineCompiler.java JasperMangler.java
                        JspCompiler.java
  Log:
  Fix an edge case where JSP pages starting with a number don't mangle correctly.
  
  The main fix is the simplest in JasperMangler.  The other two files are ports from JasperMangler.  I don't believe that JspCompiler is used anymore, and JspC isn't used much.  In any case, the fixes can't hurt.
  
  Fix for bug #6518.
  Reported by: Paul Fu paul.fu@ssmb.com.au
  
  Revision  Changes    Path
  1.7       +18 -4     jakarta-tomcat/src/share/org/apache/jasper/compiler/CommandLineCompiler.java
  
  Index: CommandLineCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/CommandLineCompiler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CommandLineCompiler.java	8 Dec 2000 23:18:34 -0000	1.6
  +++ CommandLineCompiler.java	22 Feb 2002 03:16:09 -0000	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/CommandLineCompiler.java,v 1.6 2000/12/08 23:18:34 costin Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/12/08 23:18:34 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/CommandLineCompiler.java,v 1.7 2002/02/22 03:16:09 billbarker Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/02/22 03:16:09 $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -233,8 +233,22 @@
   	
   	// Fix for invalid characters. If you think of more add to the list.
   	StringBuffer modifiedClassName = new StringBuffer();
  +	char c='/';
  +	if( Character.isDigit( className.charAt( 0 )  )) {
  +	    className="_" +className;
  +	}
   	for (int i = 0; i < className.length(); i++) {
  -	    if (Character.isLetterOrDigit(className.charAt(i)) == true)
  +	    char prev=c;
  +	    c=className.charAt(i);
  +	    // workaround for common "//" problem. Alternative
  +	    // would be to encode the dot.
  +	    if( prev=='/' && c=='/' ) {
  +		continue;
  +	    }
  +	    
  +	    if (Character.isLetterOrDigit(c) == true ||
  +		c=='_' ||
  +		c=='/' )
   		modifiedClassName.append(className.substring(i,i+1));
   	    else
   		modifiedClassName.append(mangleChar(className.charAt(i)));
  
  
  
  1.9       +2 -2      jakarta-tomcat/src/share/org/apache/jasper/compiler/JasperMangler.java
  
  Index: JasperMangler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JasperMangler.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JasperMangler.java	27 Nov 2001 04:04:12 -0000	1.8
  +++ JasperMangler.java	22 Feb 2002 03:16:09 -0000	1.9
  @@ -241,12 +241,12 @@
   
   	if( extIdx<0 ) {
   	    // no "." 
  -	    if( lastComp > 0 )
  +	    if( lastComp >= 0 )
   		baseClassN=jspFile.substring( lastComp+1 );
   	    else
   		baseClassN=jspFile.substring( 0 );
   	} else {
  -	    if( lastComp > 0 )
  +	    if( lastComp >= 0 )
   		baseClassN=jspFile.substring( lastComp+1, extIdx );
   	    else
   		baseClassN=jspFile.substring( 0, extIdx );
  
  
  
  1.20      +15 -2     jakarta-tomcat/src/share/org/apache/jasper/compiler/JspCompiler.java
  
  Index: JspCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspCompiler.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- JspCompiler.java	2 Mar 2001 04:51:32 -0000	1.19
  +++ JspCompiler.java	22 Feb 2002 03:16:09 -0000	1.20
  @@ -259,13 +259,26 @@
   	
   	// Fix for invalid characters. If you think of more add to the list.
   	StringBuffer modifiedClassName = new StringBuffer();
  +	char c='/';
  +	if( Character.isDigit( className.charAt( 0 )  )) {
  +	    className="_" +className;
  +	}
   	for (int i = 0; i < className.length(); i++) {
  -	    if (Character.isLetterOrDigit(className.charAt(i)) == true)
  +	    char prev=c;
  +	    c=className.charAt(i);
  +	    // workaround for common "//" problem. Alternative
  +	    // would be to encode the dot.
  +	    if( prev=='/' && c=='/' ) {
  +		continue;
  +	    }
  +	    
  +	    if (Character.isLetterOrDigit(c) == true ||
  +		c=='_' ||
  +		c=='/' )
   		modifiedClassName.append(className.substring(i,i+1));
   	    else
   		modifiedClassName.append(mangleChar(className.charAt(i)));
   	}
  -	
   	return modifiedClassName.toString();
       }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>