remm        01/03/30 19:00:42

  Modified:    catalina/src/share/org/apache/naming/resources
                        FileDirContext.java
  Log:
  - Fix problems under Windows where doing a request on /examples/.. would
    return a 500. Should now return a 404 instead.
  
  Revision  Changes    Path
  1.3       +21 -15    
jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/FileDirContext.java
  
  Index: FileDirContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/FileDirContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileDirContext.java       2001/02/05 04:41:08     1.2
  +++ FileDirContext.java       2001/03/31 03:00:41     1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/FileDirContext.java,v
 1.2 2001/02/05 04:41:08 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/02/05 04:41:08 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/FileDirContext.java,v
 1.3 2001/03/31 03:00:41 remm Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/03/31 03:00:41 $
    *
    * ====================================================================
    *
  @@ -98,7 +98,7 @@
    * Filesystem Directory Context implementation helper class.
    *
    * @author Remy Maucherat
  - * @version $Revision: 1.2 $ $Date: 2001/02/05 04:41:08 $
  + * @version $Revision: 1.3 $ $Date: 2001/03/31 03:00:41 $
    */
   
   public class FileDirContext extends BaseDirContext {
  @@ -848,7 +848,10 @@
           if (file.exists() && file.canRead()) {
               // Windows only check
               if ((caseSensitive) && (File.separatorChar  == '\\')) {
  -                String absPath = normalize(file.getAbsolutePath());
  +                String fileAbsPath = file.getAbsolutePath();
  +                if (fileAbsPath.endsWith("."))
  +                    fileAbsPath = fileAbsPath + "/";
  +                String absPath = normalize(fileAbsPath);
                   String canPath = null;
                   try {
                       canPath = file.getCanonicalPath();
  @@ -856,16 +859,19 @@
                           canPath = normalize(canPath);
                   } catch (IOException e) {
                   }
  -                absPath = absPath.substring(absoluteBase.length());
  -                if ((canPath == null) || (absPath == null))
  -                    return null;
  -                if (absPath.equals(""))
  -                    absPath = "/";
  -                canPath = canPath.substring(absoluteBase.length());
  -                if (canPath.equals(""))
  -                    canPath = "/";
  -                if (!canPath.equals(absPath))
  -                    return null;
  +                if ((absoluteBase.length() < absPath.length()) 
  +                    && (absoluteBase.length() < canPath.length())) {
  +                    absPath = absPath.substring(absoluteBase.length());
  +                    if ((canPath == null) || (absPath == null))
  +                        return null;
  +                    if (absPath.equals(""))
  +                        absPath = "/";
  +                    canPath = canPath.substring(absoluteBase.length());
  +                    if (canPath.equals(""))
  +                        canPath = "/";
  +                    if (!canPath.equals(absPath))
  +                        return null;
  +                }
               }
           } else {
               return null;
  
  
  

Reply via email to