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

reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/main by this push:
     new ee8ccf8ff20 [CXF-8748] Fix case-insensitive matching in PatternBuilder 
for nonProxyHosts (#2982)
ee8ccf8ff20 is described below

commit ee8ccf8ff20d221dee10175fbfb76d950d4d8ed5
Author: sstremler <[email protected]>
AuthorDate: Mon Mar 23 02:34:47 2026 +0100

    [CXF-8748] Fix case-insensitive matching in PatternBuilder for 
nonProxyHosts (#2982)
---
 .../apache/cxf/transport/http/PatternBuilder.java  |  2 +-
 .../cxf/transport/http/PatternBuilderTest.java     | 46 ++++++++++++++++------
 2 files changed, 36 insertions(+), 12 deletions(-)

diff --git 
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/PatternBuilder.java
 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/PatternBuilder.java
index 86a840be72c..89333adf0ea 100644
--- 
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/PatternBuilder.java
+++ 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/PatternBuilder.java
@@ -48,6 +48,6 @@ public final class PatternBuilder {
         String regexp = value.replace(".", "\\.");
         regexp = regexp.replace("*", ".*");
 
-        return Pattern.compile(regexp);
+        return Pattern.compile(regexp,  Pattern.CASE_INSENSITIVE);
     }
 }
diff --git 
a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/PatternBuilderTest.java
 
b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/PatternBuilderTest.java
index 4073d2cc546..40fa7e6ba5f 100644
--- 
a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/PatternBuilderTest.java
+++ 
b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/PatternBuilderTest.java
@@ -31,44 +31,68 @@ import static org.junit.Assert.assertTrue;
 public class PatternBuilderTest {
 
     @Test
-    public void testPatternBuilder() {
-
-        // Simple matching
+    public void buildPatternWithSimpleHostname() {
         Pattern pattern = PatternBuilder.build("localhost");
 
         assertTrue(pattern.matcher("localhost").matches());
+        assertTrue(pattern.matcher("LOCALHOST").matches());
         assertFalse(pattern.matcher("localhost-after").matches());
         assertFalse(pattern.matcher("before-localhost").matches());
+    }
 
-        // List matching
-        pattern = PatternBuilder.build("localhost|othername");
+    @Test
+    public void buildPatternWithPipelineDelimitedHostnames() {
+        Pattern pattern = PatternBuilder.build("localhost|othername");
 
         assertTrue(pattern.matcher("localhost").matches());
+        assertTrue(pattern.matcher("LOCALHOST").matches());
         assertTrue(pattern.matcher("othername").matches());
         assertFalse(pattern.matcher("somename").matches());
+    }
 
-        // Name with dots matching
-        pattern = PatternBuilder.build("www.apache.org");
+    @Test
+    public void buildPatternWithDotsInTheHostname() {
+        Pattern pattern = PatternBuilder.build("www.apache.org");
 
         assertTrue(pattern.matcher("www.apache.org").matches());
+        assertTrue(pattern.matcher("WWW.apache.ORG").matches());
         assertFalse(pattern.matcher("www1apache1org").matches());
+    }
 
-        // Wildcards matching 1/2
-        pattern = PatternBuilder.build("*.apache.org");
+    @Test
+    public void buildPatternWithLeadingWildcardInTheHostname() {
+        Pattern pattern = PatternBuilder.build("*.apache.org");
 
         assertTrue(pattern.matcher("www.apache.org").matches());
         assertTrue(pattern.matcher("svn.apache.org").matches());
         assertFalse(pattern.matcher("apache.org").matches());
         assertTrue(pattern.matcher(".apache.org").matches()); // not very 
useful ...
+    }
 
-        // Wildcards matching 2/2
-        pattern = PatternBuilder.build("www.apache.*");
+    @Test
+    public void buildPatternWithTrailingWildcardInTheHostname() {
+        Pattern pattern = PatternBuilder.build("www.apache.*");
 
         assertTrue(pattern.matcher("www.apache.org").matches());
         assertTrue(pattern.matcher("www.apache.net").matches());
         assertFalse(pattern.matcher("www.apache").matches());
         assertTrue(pattern.matcher("www.apache.").matches()); // not very 
useful ...
+    }
+
+    @Test
+    public void buildPatternWithUppercaseLettersInTheSimpleHostname() {
+        Pattern pattern = PatternBuilder.build("APACHE.ORG");
 
+        assertTrue(pattern.matcher("apache.org").matches());
+        assertTrue(pattern.matcher("APACHE.ORG").matches());
     }
 
+    @Test
+    public void buildPatternWithUppercaseLettersInTheLeadingWildcardHostname() 
{
+        Pattern pattern = PatternBuilder.build("*.APACHE.ORG");
+
+        assertTrue(pattern.matcher("www.apache.org").matches());
+        assertTrue(pattern.matcher("svn.apache.org").matches());
+        assertFalse(pattern.matcher("apache.org").matches());
+    }
 }
\ No newline at end of file

Reply via email to