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/04/07 21:48:13 UTC

[tomcat] branch 8.5.x updated: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63312

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 bcacd78  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63312
bcacd78 is described below

commit bcacd783e2593ae9b2c07a561bd5f95a145a7761
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Apr 30 10:57:27 2018 +0000

    Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63312
    
    Correct a regression in the error page handling that prevented error
    pages from issuing redirects or taking other action that required the
    response status code to be changed.
---
 java/org/apache/coyote/Response.java                 | 4 ----
 java/org/apache/coyote/http11/Http11InputBuffer.java | 6 ++++++
 webapps/docs/changelog.xml                           | 5 +++++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/Response.java b/java/org/apache/coyote/Response.java
index cc50bae..c3ee057 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -224,10 +224,6 @@ public final class Response {
      * @param status The status value to set
      */
     public void setStatus(int status) {
-        if (this.status > 399) {
-            // Don't overwrite first recorded error status
-            return;
-        }
         this.status = status;
     }
 
diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java b/java/org/apache/coyote/http11/Http11InputBuffer.java
index dfed9e8..620f381 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -425,6 +425,8 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler
                             pos - parsingRequestLineStart);
                 } else if (!HttpParser.isToken(chr)) {
                     byteBuffer.position(byteBuffer.position() - 1);
+                    // Avoid unknown protocol triggering an additional error
+                    request.protocol().setString(Constants.HTTP_11);
                     throw new IllegalArgumentException(sm.getString("iib.invalidmethod"));
                 }
             }
@@ -475,9 +477,13 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler
                 } else if (chr == Constants.QUESTION && parsingRequestLineQPos == -1) {
                     parsingRequestLineQPos = pos;
                 } else if (parsingRequestLineQPos != -1 && !httpParser.isQueryRelaxed(chr)) {
+                    // Avoid unknown protocol triggering an additional error
+                    request.protocol().setString(Constants.HTTP_11);
                     // %nn decoding will be checked at the point of decoding
                     throw new IllegalArgumentException(sm.getString("iib.invalidRequestTarget"));
                 } else if (httpParser.isNotRequestTargetRelaxed(chr)) {
+                    // Avoid unknown protocol triggering an additional error
+                    request.protocol().setString(Constants.HTTP_11);
                     // This is a general check that aims to catch problems early
                     // Detailed checking of each part of the request target will
                     // happen in Http11Processor#prepareRequest()
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 817501f..0bdea65 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -119,6 +119,11 @@
         request, reset the stream to inform the client that the remaining
         request body is not required. (markt)
       </fix>
+      <fix>
+        <bug>63312</bug>: Correct a regression in the error page handling that
+        prevented error pages from issuing redirects or taking other action that
+        required the response status code to be changed. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


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