You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/10/29 17:42:42 UTC

[tomcat] branch master updated: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63864

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

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


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

commit b3a8e01654549b0b79fc7c7684cd492cd5aafe4b
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 0f24e18..30dd05a 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;
@@ -208,8 +210,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")) {
@@ -722,20 +723,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 3c36184..1705743 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -92,6 +92,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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org