Author: olegk
Date: Wed Jun 21 04:05:19 2006
New Revision: 415961
URL: http://svn.apache.org/viewvc?rev=415961&view=rev
Log:
[HTTPCLIENT-588] relative URIs with internal double-slashes ('//') misparsed
Contributed by Gordon Mohr <gojomo at archive.org>
Reviewed by Oleg Kalnichevski and Roland Weber
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/viewvc/jakarta/commons/proper/httpclient/trunk/release_notes.txt?rev=415961&r1=415960&r2=415961&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/release_notes.txt (original)
+++ jakarta/commons/proper/httpclient/trunk/release_notes.txt Wed Jun 21
04:05:19 2006
@@ -1,5 +1,8 @@
Changes toward 3.1
+ * [HTTPCLIENT-588] - Fixed parsing of relative URIs with internal
double-slashes ('//')
+ Contributed by Gordon Mohr <gojomo at archive.org>
+
* [HTTPCLIENT-587] - Fixed incorrect derelativizing of relative URIs with a
scheme
Contributed by Gordon Mohr <gojomo at archive.org>
Modified:
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java?rev=415961&r1=415960&r2=415961&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
Wed Jun 21 04:05:19 2006
@@ -1919,7 +1919,8 @@
boolean isStartedFromPath = false;
int atColon = tmp.indexOf(':');
int atSlash = tmp.indexOf('/');
- if (atColon <= 0 || (atSlash >= 0 && atSlash < atColon)) {
+ if ((atColon <= 0 && !tmp.startsWith("//"))
+ || (atSlash >= 0 && atSlash < atColon)) {
isStartedFromPath = true;
}
@@ -1965,7 +1966,8 @@
if (0 <= at && at < length && tmp.charAt(at) == '/') {
// Set flag
_is_hier_part = true;
- if (at + 2 < length && tmp.charAt(at + 1) == '/') {
+ if (at + 2 < length && tmp.charAt(at + 1) == '/'
+ && !isStartedFromPath) {
// the temporary index to start the search from
int next = indexFirstOf(tmp, "/?#", at + 2);
if (next == -1) {
Modified:
jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java?rev=415961&r1=415960&r2=415961&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
Wed Jun 21 04:05:19 2006
@@ -296,4 +296,17 @@
URI derel3 = new URI(base,rel3);
assertEquals("http://www.example.com/bar",derel3.toString());
}
+
+ /**
+ * Verify proper handling of relative URIs with embedded double-slashes,
+ * like "foo//bar//baz".
+ * See bug http://issues.apache.org/jira/browse/HTTPCLIENT-588
+ *
+ * @throws Exception
+ */
+ public void testRelativeWithDoubleSlash() throws Exception {
+ URI rel = new URI("foo//bar//baz",true);
+ assertEquals("foo//bar//baz",rel.toString());
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]