Index: D:/projects/httpclient-3/src/test/org/apache/commons/httpclient/TestURI.java =================================================================== --- D:/projects/httpclient-3/src/test/org/apache/commons/httpclient/TestURI.java (revision 179776) +++ D:/projects/httpclient-3/src/test/org/apache/commons/httpclient/TestURI.java (working copy) @@ -109,7 +109,7 @@ } // the following is an array of arrays in the following order - // relative URI and resolved( scheme, host, path, query, fragment URI ) + // relative URI, scheme, host(authority), path, query, fragment, abs. URI // // these examples were taken from rfc 2396 String[][] testRelativeURIs = { @@ -154,7 +154,8 @@ { "g?y/./x", "http", "a", "/b/c/g", "y/./x", null, "http://a/b/c/g?y/./x" }, { "g?y/../x", "http", "a", "/b/c/g", "y/../x", null, "http://a/b/c/g?y/../x" }, { "g#s/./x", "http", "a", "/b/c/g", null, "s/./x", "http://a/b/c/g#s/./x" }, - { "g#s/../x", "http", "a", "/b/c/g", null, "s/../x", "http://a/b/c/g#s/../x" } + { "g#s/../x", "http", "a", "/b/c/g", null, "s/../x", "http://a/b/c/g#s/../x" }, + { ":g", "http", "a", "/b/c/:g", null, null, "http://a/b/c/:g" } // see issue #35148 }; for (int i = 0; i < testRelativeURIs.length; i++) { URI testURI = null; @@ -170,12 +171,12 @@ } try { - assertEquals( testURI.getScheme(), testRelativeURIs[i][1] ); - assertEquals( testURI.getAuthority(), testRelativeURIs[i][2] ); - assertEquals( testURI.getPath(), testRelativeURIs[i][3] ); - assertEquals( testURI.getQuery(), testRelativeURIs[i][4] ); - assertEquals( testURI.getFragment(), testRelativeURIs[i][5] ); - assertEquals( testURI.getURIReference(), testRelativeURIs[i][6] ); + assertEquals("array index "+i, testRelativeURIs[i][1], testURI.getScheme()); + assertEquals("array index "+i, testRelativeURIs[i][2], testURI.getAuthority()); + assertEquals("array index "+i, testRelativeURIs[i][3], testURI.getPath()); + assertEquals("array index "+i, testRelativeURIs[i][4], testURI.getQuery()); + assertEquals("array index "+i, testRelativeURIs[i][5], testURI.getFragment()); + assertEquals("array index "+i, testRelativeURIs[i][6], testURI.getURIReference()); } catch ( URIException e ) { fail( "error getting URI property: " + e ); } Index: D:/projects/httpclient-3/src/java/org/apache/commons/httpclient/URI.java =================================================================== --- D:/projects/httpclient-3/src/java/org/apache/commons/httpclient/URI.java (revision 179776) +++ D:/projects/httpclient-3/src/java/org/apache/commons/httpclient/URI.java (working copy) @@ -1913,7 +1913,7 @@ boolean isStartedFromPath = false; int atColon = tmp.indexOf(':'); int atSlash = tmp.indexOf('/'); - if (atColon < 0 || (atSlash >= 0 && atSlash < atColon)) { + if (atColon <= 0 || (atSlash >= 0 && atSlash < atColon)) { isStartedFromPath = true; } @@ -1936,7 +1936,7 @@ * ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? *
*/ - if (at < length && tmp.charAt(at) == ':') { + if (at > 0 && at < length && tmp.charAt(at) == ':') { char[] target = tmp.substring(0, at).toLowerCase().toCharArray(); if (validate(target, scheme)) { _scheme = target;