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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
     new ab256a5  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63864
ab256a5 is described below

commit ab256a555165db803ae2f9f7afaa3279d1050ddc
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Oct 29 18:42:12 2019 +0100

    Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63864
    
    Refactor parsing of the transfer-encoding request header to use the
    shared parsing code and reduce duplication.
---
 java/org/apache/coyote/http11/Http11Processor.java | 22 ++++++++--------------
 webapps/docs/changelog.xml                         |  5 +++++
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index e984616..bde3b6f 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -19,7 +19,9 @@ package org.apache.coyote.http11;
 import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.nio.ByteBuffer;
+import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Locale;
 import java.util.Set;
 import java.util.regex.Pattern;
@@ -450,8 +452,7 @@ public class Http11Processor extends AbstractProcessor {
      */
     private void addInputFilter(InputFilter[] inputFilters, String 
encodingName) {
 
-        // Trim provided encoding name and convert to lower case since transfer
-        // encoding names are case insensitive. (RFC2616, section 3.6)
+        // Parsing trims and converts to lower case.
         encodingName = encodingName.trim().toLowerCase(Locale.ENGLISH);
 
         if (encodingName.equals("identity")) {
@@ -965,20 +966,13 @@ public class Http11Processor extends AbstractProcessor {
         // Parse transfer-encoding header
         if (http11) {
             MessageBytes transferEncodingValueMB = 
headers.getValue("transfer-encoding");
-            if (transferEncodingValueMB != null && 
!transferEncodingValueMB.isNull()) {
-                String transferEncodingValue = 
transferEncodingValueMB.toString();
-                // Parse the comma separated list. "identity" codings are 
ignored
-                int startPos = 0;
-                int commaPos = transferEncodingValue.indexOf(',');
-                String encodingName = null;
-                while (commaPos != -1) {
-                    encodingName = transferEncodingValue.substring(startPos, 
commaPos);
+            if (transferEncodingValueMB != null) {
+                List<String> encodingNames = new ArrayList<>();
+                TokenList.parseTokenList(headers.values("transfer-encoding"), 
encodingNames);
+                for (String encodingName : encodingNames) {
+                    // "identity" codings are ignored
                     addInputFilter(inputFilters, encodingName);
-                    startPos = commaPos + 1;
-                    commaPos = transferEncodingValue.indexOf(',', startPos);
                 }
-                encodingName = transferEncodingValue.substring(startPos);
-                addInputFilter(inputFilters, encodingName);
             }
         }
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 9e6abdb..76b6c18 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -84,6 +84,11 @@
         insensitive. (markt)
       </fix>
       <fix>
+        <bug>63864</bug>: Refactor parsing of the 
<code>transfer-encoding</code>
+        request header to use the shared parsing code and reduce duplication.
+        (markt)
+      </fix>
+      <fix>
         <bug>63865</bug>: Add <code>Unset</code> option to same-site cookies
         and pass through <code>None</code> value if set by user. Patch provided
         by John Kelly. (markt)


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

Reply via email to