This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new 8b3ad14 Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63864
8b3ad14 is described below
commit 8b3ad14673c21290918ddeb38a28c6af4170e6f9
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Oct 29 18:54:46 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.
---
.../coyote/http11/AbstractHttp11Processor.java | 23 +++++++---------------
webapps/docs/changelog.xml | 5 +++++
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/java/org/apache/coyote/http11/AbstractHttp11Processor.java
b/java/org/apache/coyote/http11/AbstractHttp11Processor.java
index 2064f93..288b4ed 100644
--- a/java/org/apache/coyote/http11/AbstractHttp11Processor.java
+++ b/java/org/apache/coyote/http11/AbstractHttp11Processor.java
@@ -19,10 +19,10 @@ package org.apache.coyote.http11;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.StringReader;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
-import java.util.Locale;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -802,9 +802,7 @@ public abstract class AbstractHttp11Processor<S> extends
AbstractProcessor<S> {
*/
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)
- encodingName = encodingName.trim().toLowerCase(Locale.ENGLISH);
+ // Parsing trims and converts to lower case.
if (encodingName.equals("identity")) {
// Skip
@@ -1511,20 +1509,13 @@ public abstract class AbstractHttp11Processor<S>
extends AbstractProcessor<S> {
if (http11) {
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<String>();
+ 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);
}
// Parse content-length header
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b522a83..f150d08 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -102,6 +102,11 @@
<bug>63836</bug>: Ensure that the memory reserved for the OOME
parachute
is released when the NIO endpoint is stopped. (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>
</changelog>
</subsection>
<subsection name="Other">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]