diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java index 1793377fe..13e7ca5d8 100644 --- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java +++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java @@ -166,7 +166,7 @@ public final class PublicSuffixMatcher { result = segment; segment = nextSegment; } - return normalized; + return result; } /** diff --git a/httpclient/src/test/java/org/apache/http/conn/ssl/TestDefaultHostnameVerifier.java b/httpclient/src/test/java/org/apache/http/conn/ssl/TestDefaultHostnameVerifier.java index 744c3ca4e..b4dfbb907 100644 --- a/httpclient/src/test/java/org/apache/http/conn/ssl/TestDefaultHostnameVerifier.java +++ b/httpclient/src/test/java/org/apache/http/conn/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"; diff --git a/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixMatcher.java b/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixMatcher.java index cb986c0b8..67b216951 100644 --- a/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixMatcher.java +++ b/httpclient/src/test/java/org/apache/http/conn/util/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