hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1625255 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/client/utils/URIUtils.java test/java/org/apache/http/client/utils/TestURIUtils.java
Date Tue, 16 Sep 2014 12:07:44 GMT
Author: olegk
Date: Tue Sep 16 12:07:44 2014
New Revision: 1625255

URL: http://svn.apache.org/r1625255
Log:
Fixed IllegalArgumentException in URIUtils#extractHost thrown in case of host name containing
blanks

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java?rev=1625255&r1=1625254&r2=1625255&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
Tue Sep 16 12:07:44 2014
@@ -401,7 +401,10 @@ public class URIUtils {
             }
             final String scheme = uri.getScheme();
             if (!TextUtils.isBlank(host)) {
-                target = new HttpHost(host, port, scheme);
+                try {
+                    target = new HttpHost(host, port, scheme);
+                } catch (IllegalArgumentException ignore) {
+                }
             }
         }
         return target;

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java?rev=1625255&r1=1625254&r2=1625255&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
Tue Sep 16 12:07:44 2014
@@ -260,6 +260,8 @@ public class TestURIUtils {
                 URIUtils.extractHost(new URI("http://localhost:;sessionid=stuff/abcd")));
         Assert.assertEquals(null,
                 URIUtils.extractHost(new URI("http://:80/robots.txt")));
+        Assert.assertEquals(null,
+                URIUtils.extractHost(new URI("http://some%20domain:80/robots.txt")));
     }
 
     @Test



Mime
View raw message