commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeri...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient URI.java
Date Thu, 30 Jan 2003 00:08:43 GMT
jericho     2003/01/29 16:08:43

  Modified:    httpclient/src/java/org/apache/commons/httpclient URI.java
  Log:
  Now,
  - Treat an empty path as a relative URI in parseUriReference.
  - Treat an empty fragment in constructors (setXxxFragment was ok)
  
  Suggested by Armando Anton" <armando.anton@newknow.com>
    Mike Moran <mike_moran@mac.com> and
    Michael Becke <becke@u.washington.edu>
  
  Revision  Changes    Path
  1.28      +21 -15    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URI.java
  
  Index: URI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URI.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- URI.java	29 Jan 2003 16:03:33 -0000	1.27
  +++ URI.java	30 Jan 2003 00:08:42 -0000	1.28
  @@ -1820,7 +1820,7 @@
           throws URIException {
   
           // validate and contruct the URI character sequence
  -        if (original == null || original.length() == 0) {
  +        if (original == null) {
               throw new URIException("URI-Reference required");
           }
   
  @@ -1838,13 +1838,15 @@
           /**
            * Remove the delimiters like angle brackets around an URI.
            */
  -        char[] firstDelimiter = { tmp.charAt(0) };
  -        if (validate(firstDelimiter, delims)) {
  -            if (length >= 2) {
  -                char[] lastDelimiter = { tmp.charAt(length - 1) };
  -                if (validate(lastDelimiter, delims)) {
  -                    tmp = tmp.substring(1, length - 1);
  -                    length = length - 2;
  +        if (length > 0) {
  +            char[] firstDelimiter = { tmp.charAt(0) };
  +            if (validate(firstDelimiter, delims)) {
  +                if (length >= 2) {
  +                    char[] lastDelimiter = { tmp.charAt(length - 1) };
  +                    if (validate(lastDelimiter, delims)) {
  +                        tmp = tmp.substring(1, length - 1);
  +                        length = length - 2;
  +                    }
                   }
               }
           }
  @@ -1988,9 +1990,13 @@
            *  ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
            * </pre></blockquote><p>
            */
  -        if (0 <= at && at+1 < length && tmp.charAt(at) == '#') {
  -            _fragment = (escaped) ? tmp.substring(at + 1).toCharArray() :
  -            encode(tmp.substring(at + 1), allowed_fragment);
  +        if (0 <= at && at + 1 <= length && tmp.charAt(at) == '#')
{
  +            if (at + 1 == length) { // empty fragment
  +                _fragment = "".toCharArray();
  +            } else {
  +                _fragment = (escaped) ? tmp.substring(at + 1).toCharArray() :
  +                encode(tmp.substring(at + 1), allowed_fragment);
  +            }
           }
   
           // set this URI.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message