tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/mapper Mapper.java
Date Tue, 25 Mar 2003 18:54:40 GMT
remm        2003/03/25 10:54:40

  Modified:    util/java/org/apache/tomcat/util/http/mapper Mapper.java
  Log:
  - The wildcard mapping algorithm was incorrect. This should fix it.
  
  Revision  Changes    Path
  1.13      +42 -13    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Mapper.java	25 Mar 2003 17:52:56 -0000	1.12
  +++ Mapper.java	25 Mar 2003 18:54:40 -0000	1.13
  @@ -709,24 +709,31 @@
        */
       private final void internalMapWildcardWrapper
           (Wrapper[] wrappers, CharChunk path, MappingData mappingData) {
  +
  +        int pathEnd = path.getEnd();
  +        int pathOffset = path.getOffset();
  +
           int length = -1;
           int pos = find(wrappers, path);
           if (pos != -1) {
  +            int lastSlash = pathEnd;
               boolean found = false;
  -            while (path.startsWith(wrappers[pos].name)) {
  -                length = wrappers[pos].name.length();
  -                if (path.getLength() == length) {
  -                    found = true;
  -                    break;
  -                } else if (path.startsWithIgnoreCase("/", length)) {
  -                    found = true;
  -                    break;
  -                }
  -                pos--;
  -                if (pos < 0) {
  -                    break;
  -                }
  +            while (pos >= 0) {
  +                if (path.startsWith(wrappers[pos].name)) {
  +                    length = wrappers[pos].name.length();
  +                    if (path.getLength() == length) {
  +                        found = true;
  +                        break;
  +                    } else if (path.startsWithIgnoreCase("/", length)) {
  +                        found = true;
  +                        break;
  +                    }
  +                }
  +                lastSlash = lastSlash(path);
  +                path.setEnd(lastSlash);
  +                pos = find(wrappers, path);
               }
  +            path.setEnd(pathEnd);
               if (found) {
                   mappingData.wrapperPath.setString(wrappers[pos].name);
                   if (path.getLength() > length) {
  @@ -742,6 +749,7 @@
           }
       }
   
  +
       /**
        * Extension mappings.
        */
  @@ -916,6 +924,27 @@
               }
           }
           return result;
  +    }
  +
  +
  +    /**
  +     * Find the position of the last slash in the given char chunk.
  +     */
  +    private static final int lastSlash(CharChunk name) {
  +
  +        char[] c = name.getBuffer();
  +        int end = name.getEnd();
  +        int start = name.getStart();
  +        int pos = end;
  +
  +        while (pos > start) {
  +            if (c[--pos] == '/') {
  +                break;
  +            }
  +        }
  +
  +        return (pos);
  +
       }
   
   
  
  
  

---------------------------------------------------------------------
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