remm        2003/07/29 05:15:47

  Modified:    util/java/org/apache/tomcat/util/http/mapper Mapper.java
  Log:
  - Fix a bug redirecting to a folder: the context path was lost.
    (ex: /tomcat-docs/images -> /tomcat-docs/images/ - previsouly, it would
    get redirected to /images)
  
  Revision  Changes    Path
  1.26      +8 -6      
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/mapper/Mapper.java
  
  Index: Mapper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/mapper/Mapper.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Mapper.java       25 Jul 2003 19:25:06 -0000      1.25
  +++ Mapper.java       29 Jul 2003 12:15:47 -0000      1.26
  @@ -695,19 +695,21 @@
                       (path.getBuffer(), path.getStart(), path.getLength());
               }
               char[] buf = path.getBuffer();
  -            if( context.resources != null && buf[pathEnd -1 ] != '/') {
  +            if (context.resources != null && buf[pathEnd -1 ] != '/') {
                   Object file = null;
                   try {
                       file = context.resources.lookup(path.toString());
                   } catch(NamingException nex) {
                       // Swallow, since someone else handles the 404
                   }
  -                if(file != null && file instanceof DirContext ) {
  -                    CharChunk dirPath = path.getClone();
  -                    dirPath.append('/');
  +                if (file != null && file instanceof DirContext ) {
  +                    // Note: this mutates the path: do not do any processing 
  +                    // after this (since we set the redirectPath, there 
  +                    // shouldn't be any)
  +                    path.setOffset(pathOffset);
  +                    path.append('/');
                       mappingData.redirectPath.setChars
  -                        (dirPath.getBuffer(), dirPath.getStart(),
  -                         dirPath.getLength());
  +                        (path.getBuffer(), path.getStart(), path.getLength());
                   }
               }
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to