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

markt 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 fbb90e471b NoEqualsCookie -> CookiesWithoutEquals
fbb90e471b is described below

commit fbb90e471b002df3970e69895f970f9c45ecab16
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Aug 28 10:56:50 2024 +0100

    NoEqualsCookie -> CookiesWithoutEquals
---
 .../tomcat/util/http/CookieProcessorBase.java      | 14 ++++++------
 ...EqualsCookie.java => CookiesWithoutEquals.java} | 12 +++++------
 .../tomcat/util/http/LocalStrings.properties       |  4 ++--
 .../tomcat/util/http/LocalStrings_fr.properties    |  4 ++--
 .../tomcat/util/http/LocalStrings_ko.properties    |  4 ++--
 .../tomcat/util/http/LocalStrings_zh_CN.properties |  4 ++--
 .../tomcat/util/http/Rfc6265CookieProcessor.java   |  2 +-
 .../org/apache/tomcat/util/http/parser/Cookie.java | 25 +++++++++++-----------
 .../apache/tomcat/util/http/TestCookieParsing.java | 15 +++++++------
 test/org/apache/tomcat/util/http/TestCookies.java  | 18 ++++++++--------
 .../apache/tomcat/util/http/parser/TestCookie.java |  4 ++--
 webapps/docs/changelog.xml                         |  2 +-
 webapps/docs/config/cookie-processor.xml           |  2 +-
 13 files changed, 56 insertions(+), 54 deletions(-)

diff --git a/java/org/apache/tomcat/util/http/CookieProcessorBase.java 
b/java/org/apache/tomcat/util/http/CookieProcessorBase.java
index 54cb7de5f4..395216aeb6 100644
--- a/java/org/apache/tomcat/util/http/CookieProcessorBase.java
+++ b/java/org/apache/tomcat/util/http/CookieProcessorBase.java
@@ -42,21 +42,21 @@ public abstract class CookieProcessorBase implements 
CookieProcessor {
 
     private boolean partitioned = false;
 
-    private NoEqualsCookie noEqualsCookie = NoEqualsCookie.NAME;
+    private CookiesWithoutEquals cookiesWithoutEquals = 
CookiesWithoutEquals.NAME;
 
 
-    public String getNoEqualsCookie() {
-        return noEqualsCookie.getValue();
+    public String getCookiesWithoutEquals() {
+        return cookiesWithoutEquals.getValue();
     }
 
 
-    protected NoEqualsCookie getNoEqualsCookieInternal() {
-        return noEqualsCookie;
+    protected CookiesWithoutEquals getCookiesWithoutEqualsInternal() {
+        return cookiesWithoutEquals;
     }
 
 
-    public void setNoEqualsCookie(String noEqualsCookie) {
-        this.noEqualsCookie = NoEqualsCookie.fromString(noEqualsCookie);
+    public void setCookiesWithoutEquals(String cookiesWithoutEquals) {
+        this.cookiesWithoutEquals = 
CookiesWithoutEquals.fromString(cookiesWithoutEquals);
     }
 
 
diff --git a/java/org/apache/tomcat/util/http/NoEqualsCookie.java 
b/java/org/apache/tomcat/util/http/CookiesWithoutEquals.java
similarity index 85%
rename from java/org/apache/tomcat/util/http/NoEqualsCookie.java
rename to java/org/apache/tomcat/util/http/CookiesWithoutEquals.java
index 8d47102b95..02163a8c56 100644
--- a/java/org/apache/tomcat/util/http/NoEqualsCookie.java
+++ b/java/org/apache/tomcat/util/http/CookiesWithoutEquals.java
@@ -20,7 +20,7 @@ import java.util.Locale;
 
 import org.apache.tomcat.util.res.StringManager;
 
-public enum NoEqualsCookie {
+public enum CookiesWithoutEquals {
     IGNORE("ignore"),
     NAME("name");
     /*
@@ -34,11 +34,11 @@ public enum NoEqualsCookie {
      */
 
 
-    private static final StringManager sm = 
StringManager.getManager(NoEqualsCookie.class);
+    private static final StringManager sm = 
StringManager.getManager(CookiesWithoutEquals.class);
 
     private final String value;
 
-    NoEqualsCookie(String value) {
+    CookiesWithoutEquals(String value) {
         this.value = value;
     }
 
@@ -46,15 +46,15 @@ public enum NoEqualsCookie {
         return value;
     }
 
-    public static NoEqualsCookie fromString(String from) {
+    public static CookiesWithoutEquals fromString(String from) {
         String trimmedLower = from.trim().toLowerCase(Locale.ENGLISH);
 
-        for (NoEqualsCookie value : values()) {
+        for (CookiesWithoutEquals value : values()) {
             if (value.getValue().equals(trimmedLower)) {
                 return value;
             }
         }
 
-        throw new IllegalStateException(sm.getString("noEqualsCookie.invalid", 
from));
+        throw new 
IllegalStateException(sm.getString("cookiesWithoutEquals.invalid", from));
     }
 }
diff --git a/java/org/apache/tomcat/util/http/LocalStrings.properties 
b/java/org/apache/tomcat/util/http/LocalStrings.properties
index 0b44e2fc52..06a0e94292 100644
--- a/java/org/apache/tomcat/util/http/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/http/LocalStrings.properties
@@ -20,9 +20,9 @@ cookies.invalidSameSiteCookies=Unknown setting [{0}], must be 
one of: unset, non
 cookies.invalidSpecial=Cookies: Unknown Special Cookie
 cookies.maxCountFail=More than the maximum allowed number of cookies, [{0}], 
were detected.
 
-headers.maxCountFail=More than the maximum allowed number of headers, [{0}], 
were detected.
+cookiesWithoutEquals.invalid=The value [{0}] is not recognised
 
-noEqualsCookie.invalid=The value [{0}] is not recognised
+headers.maxCountFail=More than the maximum allowed number of headers, [{0}], 
were detected.
 
 parameters.bytes=Start processing with input [{0}]
 parameters.copyFail=Failed to create copy of original parameter values for 
debug logging purposes
diff --git a/java/org/apache/tomcat/util/http/LocalStrings_fr.properties 
b/java/org/apache/tomcat/util/http/LocalStrings_fr.properties
index 6f9d17a1eb..f8fda7638b 100644
--- a/java/org/apache/tomcat/util/http/LocalStrings_fr.properties
+++ b/java/org/apache/tomcat/util/http/LocalStrings_fr.properties
@@ -20,9 +20,9 @@ cookies.invalidSameSiteCookies=Valeur inconnue [{0}], seules 
possibles : unset,
 cookies.invalidSpecial=Cookie spécial inconnu
 cookies.maxCountFail=Le nombre maximum de cookies [{0}] est dépassé
 
-headers.maxCountFail=Le nombre d''en-têtes [{0}] dépasse le maximum autorisé
+cookiesWithoutEquals.invalid=La valeur [{0}] n''est pas reconnue
 
-noEqualsCookie.invalid=La valeur [{0}] n''est pas reconnue
+headers.maxCountFail=Le nombre d''en-têtes [{0}] dépasse le maximum autorisé
 
 parameters.bytes=Début du traitement avec les données [{0}]
 parameters.copyFail=Echec de la copie des valeurs de paramètres originaux pour 
raisons de journalisation du déboguage
diff --git a/java/org/apache/tomcat/util/http/LocalStrings_ko.properties 
b/java/org/apache/tomcat/util/http/LocalStrings_ko.properties
index a0bc692b4e..e8471c0d16 100644
--- a/java/org/apache/tomcat/util/http/LocalStrings_ko.properties
+++ b/java/org/apache/tomcat/util/http/LocalStrings_ko.properties
@@ -20,9 +20,9 @@ cookies.invalidSameSiteCookies=알 수 없는 설정 값: [{0}]. 반드시 다
 cookies.invalidSpecial=쿠키들: 알 수 없는 특별한 쿠키
 cookies.maxCountFail=허용된 최대 쿠키 개수 [{0}]을(를) 초과한 쿠키들이 탐지되었습니다.
 
-headers.maxCountFail=최대 허용 헤더 개수 [{0}]보다 더 많은 헤더들이 탐지되었습니다.
+cookiesWithoutEquals.invalid=해당 값 [{0}]은(는) 인식되지 않습니다.
 
-noEqualsCookie.invalid=해당 값 [{0}]은(는) 인식되지 않습니다.
+headers.maxCountFail=최대 허용 헤더 개수 [{0}]보다 더 많은 헤더들이 탐지되었습니다.
 
 parameters.bytes=입력 [{0}]을(를) 사용하여 처리를 시작합니다.
 parameters.copyFail=디버그 로그를 위한 원래의 파라미터 값들을 복사하지 못했습니다.
diff --git a/java/org/apache/tomcat/util/http/LocalStrings_zh_CN.properties 
b/java/org/apache/tomcat/util/http/LocalStrings_zh_CN.properties
index e0087a87d4..a698822371 100644
--- a/java/org/apache/tomcat/util/http/LocalStrings_zh_CN.properties
+++ b/java/org/apache/tomcat/util/http/LocalStrings_zh_CN.properties
@@ -20,9 +20,9 @@ cookies.invalidSameSiteCookies=未知设置[{0}],必须是以下之一:unset
 cookies.invalidSpecial=Cookies:未知特殊的Cookie
 cookies.maxCountFail=检测到超过Cookie最大允许的数量[{0}]
 
-headers.maxCountFail=检测到超过了允许设置的最大header 数[{0}]
+cookiesWithoutEquals.invalid=值[{0}]未识别
 
-noEqualsCookie.invalid=值[{0}]未识别
+headers.maxCountFail=检测到超过了允许设置的最大header 数[{0}]
 
 parameters.bytes=开始处理输入[{0}]
 parameters.copyFail=无法创建以调试日志记录为目的的原始参数值的副本
diff --git a/java/org/apache/tomcat/util/http/Rfc6265CookieProcessor.java 
b/java/org/apache/tomcat/util/http/Rfc6265CookieProcessor.java
index bd239e1571..b082ec9155 100644
--- a/java/org/apache/tomcat/util/http/Rfc6265CookieProcessor.java
+++ b/java/org/apache/tomcat/util/http/Rfc6265CookieProcessor.java
@@ -89,7 +89,7 @@ public class Rfc6265CookieProcessor extends 
CookieProcessorBase {
                 ByteChunk bc = cookieValue.getByteChunk();
 
                 Cookie.parseCookie(bc.getBytes(), bc.getStart(), 
bc.getLength(), serverCookies,
-                        getNoEqualsCookieInternal());
+                        getCookiesWithoutEqualsInternal());
             }
 
             // search from the next position
diff --git a/java/org/apache/tomcat/util/http/parser/Cookie.java 
b/java/org/apache/tomcat/util/http/parser/Cookie.java
index 75d8dd574d..26b18de75d 100644
--- a/java/org/apache/tomcat/util/http/parser/Cookie.java
+++ b/java/org/apache/tomcat/util/http/parser/Cookie.java
@@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.http.NoEqualsCookie;
+import org.apache.tomcat.util.http.CookiesWithoutEquals;
 import org.apache.tomcat.util.http.ServerCookie;
 import org.apache.tomcat.util.http.ServerCookies;
 import org.apache.tomcat.util.log.UserDataHelper;
@@ -115,21 +115,21 @@ public class Cookie {
      */
     @Deprecated
     public static void parseCookie(byte[] bytes, int offset, int len, 
ServerCookies serverCookies) {
-        parseCookie(bytes, offset, len, serverCookies, NoEqualsCookie.NAME);
+        parseCookie(bytes, offset, len, serverCookies, 
CookiesWithoutEquals.NAME);
     }
 
 
     /**
      * Parse byte array as cookie header.
      *
-     * @param bytes          Source
-     * @param offset         Start point in array
-     * @param len            Number of bytes to read
-     * @param serverCookies  Structure to store results
-     * @param noEqualsCookie How to handle a cookie name-value-pair that does 
not contain an equals character
+     * @param bytes                Source
+     * @param offset               Start point in array
+     * @param len                  Number of bytes to read
+     * @param serverCookies        Structure to store results
+     * @param cookiesWithoutEquals How to handle a cookie name-value-pair that 
does not contain an equals character
      */
     public static void parseCookie(byte[] bytes, int offset, int len, 
ServerCookies serverCookies,
-            NoEqualsCookie noEqualsCookie) {
+            CookiesWithoutEquals cookiesWithoutEquals) {
 
         // ByteBuffer is used throughout this parser as it allows the byte[]
         // and position information to be easily passed between parsing methods
@@ -147,7 +147,7 @@ public class Cookie {
         SkipResult skipResult = skipBytes(bb, VERSION_BYTES);
         if (skipResult != SkipResult.FOUND) {
             // No need to reset position since skipBytes() will have done it
-            parseCookieRfc6265(bb, serverCookies, noEqualsCookie);
+            parseCookieRfc6265(bb, serverCookies, cookiesWithoutEquals);
             return;
         }
 
@@ -158,7 +158,7 @@ public class Cookie {
             // Need to reset position as skipByte() will only have reset to
             // position before it was called
             bb.position(mark);
-            parseCookieRfc6265(bb, serverCookies, noEqualsCookie);
+            parseCookieRfc6265(bb, serverCookies, cookiesWithoutEquals);
             return;
         }
 
@@ -220,7 +220,8 @@ public class Cookie {
     }
 
 
-    private static void parseCookieRfc6265(ByteBuffer bb, ServerCookies 
serverCookies,NoEqualsCookie noEqualsCookie) {
+    private static void parseCookieRfc6265(ByteBuffer bb, ServerCookies 
serverCookies,
+            CookiesWithoutEquals cookiesWithoutEquals) {
 
         boolean moreToProcess = true;
 
@@ -261,7 +262,7 @@ public class Cookie {
 
             if (name.hasRemaining()) {
                 if (value == null) {
-                    switch (noEqualsCookie) {
+                    switch (cookiesWithoutEquals) {
                         case IGNORE: {
                             // This name-value-pair is a NO-OP
                             break;
diff --git a/test/org/apache/tomcat/util/http/TestCookieParsing.java 
b/test/org/apache/tomcat/util/http/TestCookieParsing.java
index a9640cfb83..27589bd9ad 100644
--- a/test/org/apache/tomcat/util/http/TestCookieParsing.java
+++ b/test/org/apache/tomcat/util/http/TestCookieParsing.java
@@ -127,8 +127,9 @@ public class TestCookieParsing extends TomcatBaseTest {
             /*
              * The legacy cookie processor skips all white space and non-token 
characters when looking for the cookie
              * name. This means "=bob" is parsed as a cookie with name bob. 
This behaviour was exposed when adding the
-             * tests for the noEqualsCookie option. When adding the 
noEqualsCookie option the intention was not to
-             * change the existing behaviour. Therefore this potentially 
unintended behaviour has been left unchanged.
+             * tests for the cookiesWithoutEquals option. When adding the 
cookiesWithoutEquals option the intention was
+             * not to change the existing behaviour. Therefore this 
potentially unintended behaviour has been left
+             * unchanged.
              */
             expected = COOKIES_WITH_NAME_OR_VALUE_ONLY_NAME_CONCAT + "bob=";
         } else {
@@ -142,20 +143,20 @@ public class TestCookieParsing extends TomcatBaseTest {
 
     @Test
     public void testRfc6265NameOrValueOnlyIgnore() throws Exception {
-        doTestRfc6265NoEquals("ignore", 
COOKIES_WITH_NAME_OR_VALUE_ONLY_IGNORE_CONCAT);
+        doTestRfc6265WithoutEquals("ignore", 
COOKIES_WITH_NAME_OR_VALUE_ONLY_IGNORE_CONCAT);
     }
 
 
     @Test
     public void testRfc6265NameOrValueOnlyDefault() throws Exception {
-        doTestRfc6265NoEquals(null, 
COOKIES_WITH_NAME_OR_VALUE_ONLY_NAME_CONCAT);
+        doTestRfc6265WithoutEquals(null, 
COOKIES_WITH_NAME_OR_VALUE_ONLY_NAME_CONCAT);
     }
 
 
-    private void doTestRfc6265NoEquals(String noEqualsCookie, String expected) 
throws Exception {
+    private void doTestRfc6265WithoutEquals(String cookiesWithoutEquals, 
String expected) throws Exception {
         Rfc6265CookieProcessor cookieProcessor = new Rfc6265CookieProcessor();
-        if (noEqualsCookie != null) {
-            cookieProcessor.setNoEqualsCookie(noEqualsCookie);
+        if (cookiesWithoutEquals != null) {
+            cookieProcessor.setCookiesWithoutEquals(cookiesWithoutEquals);
         }
         TestCookieParsingClient client = new 
TestCookieParsingClient(cookieProcessor, COOKIES_WITH_NAME_OR_VALUE_ONLY,
                 expected);
diff --git a/test/org/apache/tomcat/util/http/TestCookies.java 
b/test/org/apache/tomcat/util/http/TestCookies.java
index e6611bfc09..0d4020ebe0 100644
--- a/test/org/apache/tomcat/util/http/TestCookies.java
+++ b/test/org/apache/tomcat/util/http/TestCookies.java
@@ -77,7 +77,7 @@ public class TestCookies {
 
 
     @Test
-    public void testNameOnlyAreDroppedRfc6265NoEqualsName() {
+    public void testNameOnlyAreDroppedRfc6265WithoutEqualsName() {
         // Name only cookies are not dropped in RFC6265
         test(true, "foo=;a=b; ;", NAME, FOO_EMPTY, A);
         test(true, "foo;a=b; ;", NAME,  FOO_EMPTY, A);
@@ -99,7 +99,7 @@ public class TestCookies {
 
 
     @Test
-    public void testNameOnlyAreDroppedRfc6265NoEqualsIgnore() {
+    public void testNameOnlyAreDroppedRfc6265WithoutEqualsIgnore() {
         // Name only cookies are not dropped in RFC6265
         test(true, "foo=;a=b; ;", IGNORE, FOO_EMPTY, A);
         test(true, "foo;a=b; ;", IGNORE, A);
@@ -121,7 +121,7 @@ public class TestCookies {
 
 
     @Test
-    public void testNameOnlyAreDroppedRfc6265NoEqualsDefault() {
+    public void testNameOnlyAreDroppedRfc6265WithoutEqualsDefault() {
         // Name only cookies are not dropped in RFC6265
         test(true, "foo=;a=b; ;", FOO_EMPTY, A);
         test(true, "foo;a=b; ;", FOO_EMPTY, A);
@@ -168,7 +168,7 @@ public class TestCookies {
     }
 
     @Test
-    public void testEmptyPairsRfc6265NoEqualsCookieName() {
+    public void testEmptyPairsRfc6265CookiesWithoutEqualsName() {
         test(true, "foo;a=b; ;bar", NAME, FOO_EMPTY, A, BAR_EMPTY);
         test(true, "foo;a=b;;bar", NAME, FOO_EMPTY, A, BAR_EMPTY);
         test(true, "foo;a=b; ;;bar=rab", NAME, FOO_EMPTY, A, BAR);
@@ -179,7 +179,7 @@ public class TestCookies {
 
 
     @Test
-    public void testEmptyPairsRfc6265NoEqualsCookieIgnore() {
+    public void testEmptyPairsRfc6265CookiesWithoutEqualsIgnore() {
         test(true, "foo;a=b; ;bar", IGNORE, A);
         test(true, "foo;a=b;;bar", IGNORE, A);
         test(true, "foo;a=b; ;;bar=rab", IGNORE, A, BAR);
@@ -190,7 +190,7 @@ public class TestCookies {
 
 
     @Test
-    public void testEmptyPairsRfc6265NoEqualsCookieDefault() {
+    public void testEmptyPairsRfc6265CookiesWithoutEqualsDefault() {
         test(true, "foo;a=b; ;bar", FOO_EMPTY, A, BAR_EMPTY);
         test(true, "foo;a=b;;bar", FOO_EMPTY, A, BAR_EMPTY);
         test(true, "foo;a=b; ;;bar=rab", FOO_EMPTY, A, BAR);
@@ -573,15 +573,15 @@ public class TestCookies {
     }
 
 
-    private void test(boolean useRfc6265, String header, String 
noEqualsCookie, Cookie... expected) {
+    private void test(boolean useRfc6265, String header, String 
cookiesWithoutEquals, Cookie... expected) {
         MimeHeaders mimeHeaders = new MimeHeaders();
         ServerCookies serverCookies = new ServerCookies(4);
         CookieProcessor cookieProcessor;
 
         if (useRfc6265) {
             cookieProcessor = new Rfc6265CookieProcessor();
-            if (noEqualsCookie != null) {
-                ((Rfc6265CookieProcessor) 
cookieProcessor).setNoEqualsCookie(noEqualsCookie);
+            if (cookiesWithoutEquals != null) {
+                ((Rfc6265CookieProcessor) 
cookieProcessor).setCookiesWithoutEquals(cookiesWithoutEquals);
             }
         } else {
             cookieProcessor = new LegacyCookieProcessor();
diff --git a/test/org/apache/tomcat/util/http/parser/TestCookie.java 
b/test/org/apache/tomcat/util/http/parser/TestCookie.java
index 51fa4e4307..c90fca74e0 100644
--- a/test/org/apache/tomcat/util/http/parser/TestCookie.java
+++ b/test/org/apache/tomcat/util/http/parser/TestCookie.java
@@ -27,7 +27,7 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 
-import org.apache.tomcat.util.http.NoEqualsCookie;
+import org.apache.tomcat.util.http.CookiesWithoutEquals;
 import org.apache.tomcat.util.http.ServerCookies;
 
 @RunWith(Parameterized.class)
@@ -85,7 +85,7 @@ public class TestCookie {
     public void testParseThreeCookieHeader() {
         ServerCookies serverCookies = new ServerCookies(3);
         byte[] inputBytes = cookieHeader.getBytes(StandardCharsets.ISO_8859_1);
-        Cookie.parseCookie(inputBytes, 0, inputBytes.length, serverCookies, 
NoEqualsCookie.NAME);
+        Cookie.parseCookie(inputBytes, 0, inputBytes.length, serverCookies, 
CookiesWithoutEquals.NAME);
         Assert.assertEquals(3,  serverCookies.getCookieCount());
         Assert.assertEquals("first", 
serverCookies.getCookie(0).getName().toString());
         Assert.assertEquals("1", 
serverCookies.getCookie(0).getValue().toString());
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 2eec6b5f83..926e47baaa 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -115,7 +115,7 @@
         data rather than return the data it had already received. (markt)
       </fix>
       <add>
-        Add a new attribute <code>noEqualsCookie</code> to the
+        Add a new attribute <code>cookiesWithoutEquals</code> to the
         <code>Rfc6265CookieProcessor</code>. The default behaviour is 
unchanged.
         (markt)
       </add>
diff --git a/webapps/docs/config/cookie-processor.xml 
b/webapps/docs/config/cookie-processor.xml
index 11c9c30fd8..cb069388f6 100644
--- a/webapps/docs/config/cookie-processor.xml
+++ b/webapps/docs/config/cookie-processor.xml
@@ -99,7 +99,7 @@
 
     <attributes>
 
-      <attribute name="noEqualsCookie" required="false">
+      <attribute name="cookiesWithoutEquals" required="false">
         <p>Determines how a cookie received from a user agent should be
         interpreted when the name value pair does not contain an equals sign.
         The default value is <code>name</code> which means that the cookie will


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

Reply via email to