Index: src/java/org/apache/commons/httpclient/HttpsURL.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpsURL.java,v retrieving revision 1.6.2.2 diff -u -r1.6.2.2 HttpsURL.java --- src/java/org/apache/commons/httpclient/HttpsURL.java 22 Feb 2004 18:21:13 -0000 1.6.2.2 +++ src/java/org/apache/commons/httpclient/HttpsURL.java 14 May 2004 09:41:06 -0000 @@ -31,6 +31,8 @@ package org.apache.commons.httpclient; +import org.apache.commons.httpclient.util.URIUtil; + /** * The HTTPS URL. * @@ -320,11 +322,11 @@ buff.append(_default_scheme); buff.append("://"); if (userinfo != null) { - buff.append(userinfo); + buff.append(URIUtil.encode(userinfo, URI.allowed_userinfo)); buff.append('@'); } if (host != null) { - buff.append(host); + buff.append(URIUtil.encode(host, URI.allowed_host)); if (port != -1 || port != DEFAULT_PORT) { buff.append(':'); buff.append(port); @@ -336,17 +338,17 @@ throw new URIException(URIException.PARSING, "abs_path requested"); } - buff.append(path); + buff.append(URIUtil.encode(path, URI.allowed_abs_path)); } if (query != null) { buff.append('?'); - buff.append(query); + buff.append(URIUtil.encode(query, URI.allowed_query)); } if (fragment != null) { buff.append('#'); - buff.append(fragment); + buff.append(URIUtil.encode(fragment, URI.allowed_fragment)); } - parseUriReference(buff.toString(), false); + parseUriReference(buff.toString(), true); checkValid(); } Index: src/test/org/apache/commons/httpclient/TestURI.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestURI.java,v retrieving revision 1.4.2.5 diff -u -r1.4.2.5 TestURI.java --- src/test/org/apache/commons/httpclient/TestURI.java 2 May 2004 15:15:34 -0000 1.4.2.5 +++ src/test/org/apache/commons/httpclient/TestURI.java 14 May 2004 09:41:10 -0000 @@ -199,5 +199,25 @@ assertEquals("http://localhost:8080/", url.toString()); assertEquals("user:password@localhost:8080", url.getAuthority()); } + + public void testTestHttpsUrlAuthorityString() throws Exception { + HttpsURL url = new HttpsURL("localhost", -1, "/"); + assertEquals("https://localhost/", url.toString()); + url.setRawUserinfo("user".toCharArray(), "password".toCharArray()); + assertEquals("https://localhost/", url.toString()); + assertEquals("user:password@localhost", url.getAuthority()); + + url = new HttpsURL("user", "pass#", "localhost", 8080, "/"); + assertEquals("https://localhost:8080/", url.toString()); + assertEquals("user:pass#", url.getUserinfo()); + assertEquals("user:pass%23", url.getEscapedUserinfo()); + + url = new HttpsURL("localhost", 8080, "/"); + assertEquals("https://localhost:8080/", url.toString()); + url.setRawUserinfo("user".toCharArray(), "password".toCharArray()); + assertEquals("https://localhost:8080/", url.toString()); + assertEquals("user:password@localhost:8080", url.getAuthority()); + + } }