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 2019/06/27 09:16:02 UTC

[httpcomponents-client] branch HTTPCLIENT-1997 created (now b6c9688)

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a change to branch HTTPCLIENT-1997
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git.


      at b6c9688  HTTPCLIENT-1997: Return the last domain segment instead of normalized domain name from PublicSuffixMatcher#getDomainRoot in case of there is no match

This branch includes the following new commits:

     new b6c9688  HTTPCLIENT-1997: Return the last domain segment instead of normalized domain name from PublicSuffixMatcher#getDomainRoot in case of there is no match

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[httpcomponents-client] 01/01: HTTPCLIENT-1997: Return the last domain segment instead of normalized domain name from PublicSuffixMatcher#getDomainRoot in case of there is no match

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch HTTPCLIENT-1997
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git

commit b6c9688e21a3b55677913aeacc1eb80aabc86b4b
Author: jeromedemangel <je...@gmail.com>
AuthorDate: Wed Jun 26 14:45:31 2019 +0200

    HTTPCLIENT-1997: Return the last domain segment instead of normalized domain name from PublicSuffixMatcher#getDomainRoot in case of there is no match
---
 .../org/apache/hc/client5/http/psl/PublicSuffixMatcher.java  |  2 +-
 .../apache/hc/client5/http/psl/TestPublicSuffixMatcher.java  |  4 +++-
 .../hc/client5/http/ssl/TestDefaultHostnameVerifier.java     | 12 ++++++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java
index 4ddaf00..29c50dc 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java
@@ -171,7 +171,7 @@ public final class PublicSuffixMatcher {
             result = segment;
             segment = nextSegment;
         }
-        return normalized;
+        return result;
     }
 
     /**
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java
index bf6a2e6..071d4cc 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java
@@ -69,7 +69,9 @@ public class TestPublicSuffixMatcher {
         Assert.assertEquals("blah.blah.tokyo.jp", matcher.getDomainRoot("blah.blah.tokyo.jp"));
         Assert.assertEquals("blah.ac.jp", matcher.getDomainRoot("blah.blah.ac.jp"));
         Assert.assertEquals("garbage", matcher.getDomainRoot("garbage"));
-        Assert.assertEquals("garbage.garbage", matcher.getDomainRoot("garbage.garbage"));
+        Assert.assertEquals("garbage", matcher.getDomainRoot("garbage.garbage"));
+        Assert.assertEquals("garbage", matcher.getDomainRoot("*.garbage.garbage"));
+        Assert.assertEquals("garbage", matcher.getDomainRoot("*.garbage.garbage.garbage"));
     }
 
     @Test
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java
index 732451f..bd961d3 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java
@@ -275,6 +275,18 @@ public class TestDefaultHostnameVerifier {
         Assert.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("mail.a.b.c.com", "m*.a.b.c.com"));
     }
 
+    @Test
+    public void testHTTPCLIENT_1997() {
+        Assert.assertTrue(DefaultHostnameVerifier.matchIdentity(
+                "service.apps.dev.b.cloud.a", "*.apps.dev.b.cloud.a"));
+        Assert.assertTrue(DefaultHostnameVerifier.matchIdentityStrict(
+                "service.apps.dev.b.cloud.a", "*.apps.dev.b.cloud.a"));
+        Assert.assertTrue(DefaultHostnameVerifier.matchIdentity(
+                "service.apps.dev.b.cloud.a", "*.apps.dev.b.cloud.a", publicSuffixMatcher));
+        Assert.assertTrue(DefaultHostnameVerifier.matchIdentityStrict(
+                "service.apps.dev.b.cloud.a", "*.apps.dev.b.cloud.a", publicSuffixMatcher));
+    }
+
     @Test // Check compressed IPv6 hostname matching
     public void testHTTPCLIENT_1316() throws Exception{
         final String host1 = "2001:0db8:aaaa:bbbb:cccc:0:0:0001";