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 2003/09/14 06:17:47 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/io FileUtil.java

billbarker    2003/09/13 21:17:47

  Modified:    src/share/org/apache/tomcat/util/io FileUtil.java
  Log:
  Add a check for case-insensitive for Windows platforms.
  
  Fix for bug #23101
  Reported By: Daniele Gaffuri gaffuri@reply.it
  
  Revision  Changes    Path
  1.10      +13 -6     jakarta-tomcat/src/share/org/apache/tomcat/util/io/FileUtil.java
  
  Index: FileUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/io/FileUtil.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FileUtil.java	13 Sep 2002 05:43:48 -0000	1.9
  +++ FileUtil.java	14 Sep 2003 04:17:47 -0000	1.10
  @@ -136,6 +136,14 @@
   
       */
       public static String safePath( String base, String path ) {
  +	return safePath(base, path, true);
  +    }
  +
  +    /** All the safety checks from getRealPath() and
  +	DefaultServlet.
  +
  +    */
  +    public static String safePath( String base, String path, boolean caseSf ) {
   	// Hack for Jsp ( and other servlets ) that use rel. paths 
   	// if( ! path.startsWith("/") ) path="/"+ path;
   	if( path==null || path.equals("") ) return base;
  @@ -202,9 +210,8 @@
   	if (File.separatorChar  == '\\') {
   	    // On Windows check ignore case....
   	    if (!realPath.equals(canPath)){
  -            int ls=realPath.lastIndexOf('\\');
  -            if ( (ls > 0) && !realPath.substring(0,ls).equals(canPath) )
  -        		return null;
  +		if(caseSf || !realPath.equalsIgnoreCase(canPath))
  +		    return null;
   	    }
   	}