(tomcat) branch main updated: Revert

[email protected] Mon, 03 Aug 2026 19:28:46 +0000
Newsgroups gmane.comp.jakarta.tomcat.devel
Message-ID <178578532613.3049716.16780906613290505236@gitbox3-he-fi.apache.org>
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
     new 07193527d1 Revert
07193527d1 is described below

commit 07193527d198d91a1973fe707b0e1a8820aab6ec
Author: remm <[email protected]>
AuthorDate: Mon Aug 3 21:28:33 2026 +0200

    Revert
    
    Remove bad javadoc examples instead.
---
 java/org/apache/coyote/CompressionConfig.java      |  5 +-
 .../coyote/http11/AbstractHttp11Protocol.java      |  3 +-
 java/org/apache/coyote/http11/Http11Processor.java |  2 +-
 .../coyote/TestCompressionConfigUserAgents.java    | 67 ----------------------
 .../apache/coyote/http11/TestHttp11Processor.java  | 34 -----------
 webapps/docs/changelog.xml                         | 12 ----
 6 files changed, 4 insertions(+), 119 deletions(-)

diff --git a/java/org/apache/coyote/CompressionConfig.java b/java/org/apache/coyote/CompressionConfig.java
index ce8ffc1a6f..537a39624e 100644
--- a/java/org/apache/coyote/CompressionConfig.java
+++ b/java/org/apache/coyote/CompressionConfig.java
@@ -168,8 +168,7 @@ public class CompressionConfig {
 
 
     /**
-     * Set no compression user agent pattern. Regular expression as supported by {@link Pattern}. e.g.:
-     * <code>gorilla|desesplorer|tigrus</code>.
+     * Set no compression user agent pattern. Regular expression as supported by {@link Pattern}.
      *
      * @param noCompressionUserAgents The regular expression for user agent strings for which compression should not be
      *                                    applied
@@ -375,7 +374,7 @@ public class CompressionConfig {
                 MessageBytes userAgentValueMB = request.getMimeHeaders().getValue("user-agent");
                 if (userAgentValueMB != null) {
                     String userAgentValue = userAgentValueMB.toString();
-                    if (noCompressionUserAgents.matcher(userAgentValue).find()) {
+                    if (noCompressionUserAgents.matcher(userAgentValue).matches()) {
                         return false;
                     }
                 }
diff --git a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
index 9f6327c695..3bc72c0c52 100644
--- a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
+++ b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
@@ -548,8 +548,7 @@ public abstract class AbstractHttp11Protocol<S> extends AbstractProtocol<S> {
      * Set restricted user agent list (which will downgrade the connector to HTTP/1.0 mode). Regular expression as
      * supported by {@link Pattern}.
      *
-     * @param restrictedUserAgents The regular expression as supported by {@link Pattern} for the user agents e.g.
-     *                                 "gorilla|desesplorer|tigrus"
+     * @param restrictedUserAgents The regular expression as supported by {@link Pattern} for the user agents
      */
     public void setRestrictedUserAgents(String restrictedUserAgents) {
         if (restrictedUserAgents == null || restrictedUserAgents.isEmpty()) {
diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java
index 93ee050d7e..dd1a18022b 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -652,7 +652,7 @@ public class Http11Processor extends AbstractProcessor {
             // and keepAlive flags accordingly
             if (userAgentValueMB != null && !userAgentValueMB.isNull()) {
                 String userAgentValue = userAgentValueMB.toString();
-                if (restrictedUserAgents.matcher(userAgentValue).find()) {
+                if (restrictedUserAgents.matcher(userAgentValue).matches()) {
                     http11 = false;
                     keepAlive = false;
                 }
diff --git a/test/org/apache/coyote/TestCompressionConfigUserAgents.java b/test/org/apache/coyote/TestCompressionConfigUserAgents.java
deleted file mode 100644
index 43f988533f..0000000000
--- a/test/org/apache/coyote/TestCompressionConfigUserAgents.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.coyote;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestCompressionConfigUserAgents {
-
-    @Test
-    public void testNoCompressionUserAgents() {
-        CompressionConfig config = new CompressionConfig();
-        config.setNoCompressionUserAgents("gorilla|MSIE|tigrus");
-
-        Request request = new Request();
-        request.getMimeHeaders().addValue("accept-encoding").setString("gzip");
-        Response response;
-
-        // Force mode (compressionLevel == 2) skips the user-agent check,
-        // so use "on" mode where the check applies
-        config.setCompression("on");
-
-        // User-agent matching the pattern should not be compressed
-        response = createResponse();
-        request.getMimeHeaders().addValue("user-agent").setString("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
-        Assert.assertFalse(config.useCompression(request, response));
-
-        // No user-agent header should be compressed
-        response = createResponse();
-        request.getMimeHeaders().removeHeader("user-agent");
-        Assert.assertTrue(config.useCompression(request, response));
-
-        // User-agent not matching the pattern should be compressed
-        response = createResponse();
-        request.getMimeHeaders().removeHeader("user-agent");
-        request.getMimeHeaders().addValue("user-agent").setString("Mozilla/5.0 (X11; Linux x86_64)");
-        Assert.assertTrue(config.useCompression(request, response));
-
-        // Force mode skips the user-agent check
-        response = createResponse();
-        config.setCompression("force");
-        request.getMimeHeaders().removeHeader("user-agent");
-        request.getMimeHeaders().addValue("user-agent").setString("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
-        Assert.assertTrue(config.useCompression(request, response));
-    }
-
-    private Response createResponse() {
-        Response response = new Response();
-        response.setContentLength(4096);
-        response.setContentType("text/html");
-        return response;
-    }
-}
diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java b/test/org/apache/coyote/http11/TestHttp11Processor.java
index bdaa375c99..8bb298c849 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -2203,38 +2203,4 @@ public class TestHttp11Processor extends TomcatBaseTest {
     }
 
 
-    @Test
-    public void testRestrictedUserAgents() throws Exception {
-        Tomcat tomcat = getTomcatInstance();
-
-        // No file system docBase required
-        Context ctx = getProgrammaticRootContext();
-
-        Tomcat.addServlet(ctx, "TesterServlet", new TesterServlet());
-        ctx.addServletMappingDecoded("/*", "TesterServlet");
-
-        // Set restricted user agents to match "MSIE"
-        Assert.assertTrue(tomcat.getConnector().setProperty("restrictedUserAgents", "gorilla|desesplorer|MSIE|tigrus"));
-
-        tomcat.start();
-
-        // User-agent matching the pattern should be downgraded to HTTP/1.0
-        // @formatter:off
-        String request =
-                "GET /test HTTP/1.1" + CRLF +
-                "Host: any" + CRLF +
-                "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" + CRLF +
-                CRLF;
-        // @formatter:on
-
-        Client client = new Client(tomcat.getConnector().getLocalPort());
-        client.setRequest(new String[] { request });
-
-        client.connect();
-        client.processRequest();
-
-        // Should be downgraded to HTTP/1.0, although the server will still advertise HTTP/1.1
-        Assert.assertTrue(client.isResponse200());
-        Assert.assertTrue(client.getResponseHeaders().contains("Connection: close"));
-    }
 }
\ No newline at end of file
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 2ebfb72332..173f38f99e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -339,18 +339,6 @@
         of how early in the HEADERS frame processing an error is detected.
         (markt)
       </fix>
-      <fix>
-        Fix matching the compression config
-        <code>noCompressionUserAgents</code> with patterns of the style
-        of the example <code>gorilla|desesplorer|tigrus</code> pattern
-        documented in the javadoc. (remm)
-      </fix>
-      <fix>
-        Fix matching the HTTP/1.1 connector
-        <code>restrictedUserAgents</code> with patterns of the style
-        of the example <code>gorilla|desesplorer|tigrus</code> pattern
-        documented in the javadoc. (remm)
-      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">