(tomcat) branch 9.0.x updated: Revert
[email protected] Mon, 03 Aug 2026 19:30:38 +0000
| Newsgroups | gmane.comp.jakarta.tomcat.devel |
|---|---|
| Message-ID | <178578543850.3054851.10110313752861859177@gitbox3-he-fi.apache.org> |
This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new dc8976028a Revert
dc8976028a is described below
commit dc8976028a35d58eaddb9677af9407609f6f75d1
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 4de050b1df..78b320ba9a 100644
--- a/java/org/apache/coyote/CompressionConfig.java
+++ b/java/org/apache/coyote/CompressionConfig.java
@@ -174,8 +174,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
@@ -409,7 +408,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 8a24e099e5..08037a5b0d 100644
--- a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
+++ b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
@@ -646,8 +646,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 d07369499d..9172073405 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -674,7 +674,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 5060b4ff6f..96a588dd2d 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 a3cf7eb9d5..7002dcced3 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -190,18 +190,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">