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

remm pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 5659a49483 Fix edge case
5659a49483 is described below

commit 5659a49483ce53c7c59bc2e17f381ed1a6f54346
Author: remm <r...@apache.org>
AuthorDate: Wed Dec 11 12:05:34 2024 +0100

    Fix edge case
---
 java/org/apache/catalina/servlets/DefaultServlet.java | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java 
b/java/org/apache/catalina/servlets/DefaultServlet.java
index 3ef2735bb9..c846c67c78 100644
--- a/java/org/apache/catalina/servlets/DefaultServlet.java
+++ b/java/org/apache/catalina/servlets/DefaultServlet.java
@@ -2159,7 +2159,9 @@ public class DefaultServlet extends HttpServlet {
             return true;
         }
         boolean hasAsteriskValue = false;// check existence of special header 
value '*'
+        int headerCount = 0;
         while (headerValues.hasMoreElements() && !conditionSatisfied) {
+            headerCount++;
             String headerValue = headerValues.nextElement();
             if ("*".equals(headerValue)) {
                 hasAsteriskValue = true;
@@ -2178,7 +2180,11 @@ public class DefaultServlet extends HttpServlet {
                 }
             }
         }
-        if (hasAsteriskValue && headerValues.hasMoreElements()) {
+        if (headerValues.hasMoreElements()) {
+            headerCount++;
+        }
+
+        if (hasAsteriskValue && headerCount > 1) {
             // Note that an If-Match header field with a list value containing 
"*" and other values (including other
             // instances of "*") is syntactically invalid (therefore not 
allowed to be generated) and furthermore is
             // unlikely to be interoperable.
@@ -2253,13 +2259,14 @@ public class DefaultServlet extends HttpServlet {
         }
         boolean hasAsteriskValue = false;// check existence of special header 
value '*'
         boolean conditionSatisfied = true;
+        int headerCount = 0;
         while (headerValues.hasMoreElements()) {
-
+            headerCount++;
             String headerValue = headerValues.nextElement();
 
             if (headerValue.equals("*")) {
                 hasAsteriskValue = true;
-                if (headerValues.hasMoreElements()) {
+                if (headerCount > 1 || headerValues.hasMoreElements()) {
                     conditionSatisfied = false;
                     break;
                 } else {
@@ -2299,8 +2306,11 @@ public class DefaultServlet extends HttpServlet {
             }
 
         }
+        if (headerValues.hasMoreElements()) {
+            headerCount++;
+        }
 
-        if (hasAsteriskValue && headerValues.hasMoreElements()) {
+        if (hasAsteriskValue && headerCount > 1) {
             // Note that an If-None-Match header field with a list value 
containing "*" and other values (including
             // other instances of "*") is syntactically invalid (therefore not 
allowed to be generated) and furthermore
             // is unlikely to be interoperable.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to