jericho     01/05/05 23:10:14

  Modified:    src/util/org/apache/util GenericURI.java
  Log:
  - Change the direction for paring the special characters for the generic URI.
    If the URI is not escaped, it's failed to parse and obviously a bug.
  
  Revision  Changes    Path
  1.4       +22 -21    jakarta-slide/src/util/org/apache/util/GenericURI.java
  
  Index: GenericURI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/util/org/apache/util/GenericURI.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GenericURI.java   2001/05/05 15:34:51     1.3
  +++ GenericURI.java   2001/05/06 06:10:14     1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/GenericURI.java,v 1.3 
2001/05/05 15:34:51 jericho Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/05/05 15:34:51 $
  + * $Header: /home/cvs/jakarta-slide/src/util/org/apache/util/GenericURI.java,v 1.4 
2001/05/06 06:10:14 jericho Exp $
  + * $Revision: 1.4 $
  + * $Date: 2001/05/06 06:10:14 $
    *
    * ====================================================================
    *
  @@ -666,7 +666,7 @@
           throws MalformedURLException {
   
           String authority = getEscapedAuthority(escapedURI);
  -        int at = authority.indexOf("@");
  +        int at = authority.lastIndexOf("@");
   
           return (at > 0) ? authority.substring(at + 1) : authority;
       }
  @@ -723,7 +723,7 @@
           throws MalformedURLException {
   
           String hostPort = getEscapedHostPort(escapedURI);
  -        int to = hostPort.indexOf(":");
  +        int to = hostPort.lastIndexOf(":");
   
           return (to > 0) ? hostPort.substring(0, to) : hostPort;
       }
  @@ -768,7 +768,7 @@
           throws MalformedURLException {
   
           String hostPort = getEscapedHostPort(escapedURI);
  -        int at = hostPort.indexOf(":");
  +        int at = hostPort.lastIndexOf(":");
           if (at > 0) {
               String port = URIUtil.unescape(hostPort.substring(at + 1));
               try {
  @@ -838,8 +838,8 @@
           int to = escapedURI.length();
           // Ignore the '?' mark so to ignore the query.
           // check the fragment
  -        if (escapedURI.indexOf("#") > from)
  -            to = escapedURI.indexOf("#");
  +        if (escapedURI.lastIndexOf("#") > from)
  +            to = escapedURI.lastIndexOf("#");
           // get only the path.
           return (from >= 0) ? escapedURI.substring(from, to) : null;
       }
  @@ -899,8 +899,8 @@
           int to = escapedURI.length();
           // Ignore the '?' mark so to ignore the query.
           // check the fragment
  -        if (escapedURI.indexOf("#") > from)
  -            to = escapedURI.indexOf("#");
  +        if (escapedURI.lastIndexOf("#") > from)
  +            to = escapedURI.lastIndexOf("#");
           // get only the wanted path.
           return (from >= 0) ? escapedURI.substring(from, to) : "/";
       }
  @@ -971,11 +971,12 @@
           // Ignore the authority part of URI
           int to = escapedURI.length();
           // check the query
  -        if (escapedURI.indexOf("?") > from)
  -            to = escapedURI.indexOf("?");
  +        if (escapedURI.lastIndexOf("?") > from)
  +            to = escapedURI.lastIndexOf("?");
           // check the fragment
  -        if (escapedURI.indexOf("#") > from && escapedURI.indexOf("#") < to)
  -            to = escapedURI.indexOf("#");
  +        if (escapedURI.lastIndexOf("#") > from &&
  +            escapedURI.lastIndexOf("#") < to)
  +            to = escapedURI.lastIndexOf("#");
           // get only the path.
           return (from >= 0) ? escapedURI.substring(from, to) : "/";
       }
  @@ -1115,13 +1116,13 @@
               escapedURI.indexOf("/");
           if (at > 0) {
               // check the query
  -            int from = (escapedURI.indexOf("?", at) > 0) ?
  -                escapedURI.indexOf("?") + 1 : -1;
  +            int from = (escapedURI.lastIndexOf("?", at) > 0) ?
  +                escapedURI.lastIndexOf("?") + 1 : -1;
               int to = escapedURI.length();
               // check the fragment
  -            if (escapedURI.indexOf("#", at) > at &&
  -                escapedURI.indexOf("#", at) < to)
  -                to = escapedURI.indexOf("#");
  +            if (escapedURI.lastIndexOf("#", at) > at &&
  +                escapedURI.lastIndexOf("#", at) < to)
  +                to = escapedURI.lastIndexOf("#");
               return (from > 0) ? escapedURI.substring(from, to) : null;
           } else
               throw new MalformedURLException("Need to have the path part");
  @@ -1190,8 +1191,8 @@
               escapedURI.indexOf("/");
           if (at > 0) {
               // check the fragment
  -            int from = (escapedURI.indexOf("#", at) > 0) ?
  -                escapedURI.indexOf("#", at) + 1 : -1;
  +            int from = (escapedURI.lastIndexOf("#", at) > 0) ?
  +                escapedURI.lastIndexOf("#", at) + 1 : -1;
               return (from > 0) ? escapedURI.substring(from) : null;
           } else
               throw new MalformedURLException("Need to have the path part");
  
  
  

Reply via email to