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" <[EMAIL PROTECTED]>
Mike Moran <[EMAIL PROTECTED]> and
Michael Becke <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]