svn commit: r179784 - in /jakarta/commons/proper/httpclient/trunk: release_notes.txt src/java/org/apache/commons/httpclient/URI.java src/test/org/apache/commons/httpclient/TestURI.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r179784 - in /jakarta/commons/proper/httpclient/trunk: release_notes.txt src/java/org/apache/commons/httpclient/URI.java src/test/org/apache/commons/httpclient/TestURI.java

oglueck
Author: oglueck
Date: Fri Jun  3 06:18:34 2005
New Revision: 179784

URL: http://svn.apache.org/viewcvs?rev=179784&view=rev
Log:
fixed relative URIs beginning with a colon.
PR: 35148
Contributed by: Gordon Mohr
Reviewed by: Oleg Kalnichevsky, Ortwin Gl├╝ck

Modified:
    jakarta/commons/proper/httpclient/trunk/release_notes.txt
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java

Modified: jakarta/commons/proper/httpclient/trunk/release_notes.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/release_notes.txt?rev=179784&r1=179783&r2=179784&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/release_notes.txt (original)
+++ jakarta/commons/proper/httpclient/trunk/release_notes.txt Fri Jun  3 06:18:34 2005
@@ -1,4 +1,6 @@
 Changes since Release Candidate 2:
+ * 35148 - HttpClient now correctly handles relative URIs beginning with a colon.
+           Contributed by Gordon Mohr <gojomo at archive.org>
 
  * 34961 - HttpClient now correctly handles escaped characters in HTTP header elements
            Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java?rev=179784&r1=179783&r2=179784&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java Fri Jun  3 06:18:34 2005
@@ -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 @@
          *  ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
          * </pre></blockquote><p>
          */
-        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;

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java?rev=179784&r1=179783&r2=179784&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java (original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java Fri Jun  3 06:18:34 2005
@@ -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 );
             }            



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]