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

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


The following commit(s) were added to refs/heads/main by this push:
     new 1d785c7725 Need to override all the sendRedirect() methods to handle 
include
1d785c7725 is described below

commit 1d785c77258190e3f2958c26369afb5c7aef0fcf
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Mar 14 15:45:59 2023 +0000

    Need to override all the sendRedirect() methods to handle include
    
    Applications can call any sendRedirect() method. If we don't override
    them all, the redirect may be passed to the wrapped request where it
    will be processed.
---
 .../catalina/core/ApplicationHttpResponse.java     | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/java/org/apache/catalina/core/ApplicationHttpResponse.java 
b/java/org/apache/catalina/core/ApplicationHttpResponse.java
index 75f882fff2..88e0115219 100644
--- a/java/org/apache/catalina/core/ApplicationHttpResponse.java
+++ b/java/org/apache/catalina/core/ApplicationHttpResponse.java
@@ -256,6 +256,45 @@ class ApplicationHttpResponse extends 
HttpServletResponseWrapper {
     }
 
 
+    /**
+     * {@inheritDoc}
+     * <p>
+     * Disallow <code>sendRedirect()</code> calls on an included response.
+     */
+    @Override
+    public void sendRedirect(String location) throws IOException {
+        if (!included) {
+            ((HttpServletResponse) getResponse()).sendRedirect(location);
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * Disallow <code>sendRedirect()</code> calls on an included response.
+     */
+    @Override
+    public void sendRedirect(String location, int sc) throws IOException {
+        if (!included) {
+            ((HttpServletResponse) getResponse()).sendRedirect(location, sc);
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * Disallow <code>sendRedirect()</code> calls on an included response.
+     */
+    @Override
+    public void sendRedirect(String location, boolean clearBuffer) throws 
IOException {
+        if (!included) {
+            ((HttpServletResponse) getResponse()).sendRedirect(location, 
clearBuffer);
+        }
+    }
+
+
     /**
      * {@inheritDoc}
      * <p>


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

Reply via email to