You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/09/29 07:56:07 UTC
[httpcomponents-client] branch 5.0.x updated: Incorrect handling of
malformed authority component by URIUtils#extractHost
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch 5.0.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
The following commit(s) were added to refs/heads/5.0.x by this push:
new 7cc22af Incorrect handling of malformed authority component by URIUtils#extractHost
7cc22af is described below
commit 7cc22af931372c1a9c4bc226985801b13d659223
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Sep 29 09:37:38 2020 +0200
Incorrect handling of malformed authority component by URIUtils#extractHost
---
.../src/main/java/org/apache/hc/client5/http/utils/URIUtils.java | 2 +-
.../src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/utils/URIUtils.java b/httpclient5/src/main/java/org/apache/hc/client5/http/utils/URIUtils.java
index bf53275..15c7115 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/utils/URIUtils.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/utils/URIUtils.java
@@ -259,7 +259,7 @@ public class URIUtils {
host = uri.getAuthority();
if (host != null) {
// Strip off any leading user credentials
- final int at = host.indexOf('@');
+ final int at = host.lastIndexOf('@');
if (at >= 0) {
if (host.length() > at+1 ) {
host = host.substring(at+1);
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java
index e2d0340..8429db4 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java
@@ -238,6 +238,8 @@ public class TestURIUtils {
URIUtils.extractHost(new URI("http://:80/robots.txt")));
Assert.assertEquals(null,
URIUtils.extractHost(new URI("http://some%20domain:80/robots.txt")));
+ Assert.assertEquals(new HttpHost("google.com", -1),
+ URIUtils.extractHost(new URI("http://blah@goggle.com:80@google.com/")));
}
@Test