You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2022/11/24 10:18:15 UTC

[cxf] branch 3.5.x-fixes updated (d728e5807c -> ae855ac675)

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

coheigea pushed a change to branch 3.5.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


    from d728e5807c Recording .gitmergeinfo Changes
     new a1b5578cf9 Don't use redirect-query-check with the static resource list (#1034)
     new ae855ac675 Recording .gitmergeinfo Changes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                        |  1 +
 .../cxf/transport/servlet/AbstractHTTPServlet.java   |  8 ++++----
 .../jaxrs/JAXRSClientServerSpringBookTest.java       | 10 ++++++++++
 .../jaxrs/src/test/resources/jaxrs/WEB-INF/web.xml   | 20 ++++++++++++++++++++
 4 files changed, 35 insertions(+), 4 deletions(-)


[cxf] 02/02: Recording .gitmergeinfo Changes

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.5.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit ae855ac675864ac452f617c885c599d74cb39ad9
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Thu Nov 24 09:11:33 2022 +0000

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 65fffe6152..86f651de1c 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -6,6 +6,7 @@ B 0fd59b2a26240e290fdc646decc4c5c467875f62
 B 12a68910220a3af6fe2d0419a3556320b75c3523
 B 14fde35cbb22f301217be8e1b56ef405eab70682
 B 210cd832ef91c2f95569859b45b59c846d54ff97
+B 2138d98dc708e883f638e35abc53065f99b9961b
 B 21531a4049139798c4f4efd546235648b8084c53
 B 21afd81b648cebe854ba567cbebd22a4ce386992
 B 21bf42d906765fffb015f86d49e7b535d927bc56


[cxf] 01/02: Don't use redirect-query-check with the static resource list (#1034)

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.5.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit a1b5578cf9175f27793a7fc0a9070f92aab5d2d5
Author: Colm O hEigeartaigh <co...@users.noreply.github.com>
AuthorDate: Wed Nov 23 21:10:59 2022 +0000

    Don't use redirect-query-check with the static resource list (#1034)
    
    (cherry picked from commit b18d7928c2cfdcd44df8c38efdc4cd9333873942)
    (cherry picked from commit a7b731059a9285aa9cc933be2caf62e14c582256)
---
 .../cxf/transport/servlet/AbstractHTTPServlet.java   |  8 ++++----
 .../jaxrs/JAXRSClientServerSpringBookTest.java       | 10 ++++++++++
 .../jaxrs/src/test/resources/jaxrs/WEB-INF/web.xml   | 20 ++++++++++++++++++++
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java
index 621a895414..5eb95651d8 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/AbstractHTTPServlet.java
@@ -285,14 +285,14 @@ public abstract class AbstractHTTPServlet extends HttpServlet implements Filter
     protected void handleRequest(HttpServletRequest request, HttpServletResponse response)
         throws ServletException {
         if ((dispatcherServletPath != null || dispatcherServletName != null)
-            && (redirectList != null && matchPath(redirectList, request)
+            && (redirectList != null && matchPath(redirectQueryCheck, redirectList, request)
                 || redirectList == null)) {
             // if no redirectList is provided then this servlet is redirecting only
             redirect(request, response, request.getPathInfo());
             return;
         }
         boolean staticResourcesMatch = staticResourcesList != null
-            && matchPath(staticResourcesList, request);
+            && matchPath(false, staticResourcesList, request);
         boolean staticWelcomeFileMatch = staticWelcomeFile != null
             && (StringUtils.isEmpty(request.getPathInfo()) || "/".equals(request.getPathInfo()));
         if (staticResourcesMatch || staticWelcomeFileMatch) {
@@ -329,12 +329,12 @@ public abstract class AbstractHTTPServlet extends HttpServlet implements Filter
     }
 
 
-    private boolean matchPath(List<Pattern> values, HttpServletRequest request) {
+    private static boolean matchPath(boolean checkRedirect, List<Pattern> values, HttpServletRequest request) {
         String path = request.getPathInfo();
         if (path == null) {
             path = "/";
         }
-        if (redirectQueryCheck) {
+        if (checkRedirect) {
             String queryString = request.getQueryString();
             if (queryString != null && !queryString.isEmpty()) {
                 path += "?" + queryString;
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
index d4efbf16b4..4456c564ec 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
@@ -148,6 +148,7 @@ public class JAXRSClientServerSpringBookTest extends AbstractBusClientServerTest
         assertFalse(s.contains(";a=b"));
         assertTrue(s.contains("<a href=\"http://localhost:" + PORT + "/the/"));
     }
+
     @Test
     public void testGetServicesPageWithServletPatternMatchOnly2() throws Exception {
         final String address = "http://localhost:" + PORT + "/services;a=b;/list;a=b/;a=b";
@@ -159,6 +160,15 @@ public class JAXRSClientServerSpringBookTest extends AbstractBusClientServerTest
         assertTrue(s.contains("<a href=\"http://localhost:" + PORT + "/services/list/"));
     }
 
+    @Test
+    public void testStaticResourcesWithRedirectQueryCheck() throws Exception {
+        final String address = "http://localhost:" + PORT + "/services/?.html";
+        WebClient wc = WebClient.create(address).accept("text/*");
+        String s = wc.get(String.class);
+        // Check we don't have a directory listing
+        assertFalse(s.contains("META-INF"));
+    }
+
     @Test
     public void testEchoBookForm() throws Exception {
         String address = "http://localhost:" + PORT + "/bus/thebooksform/bookform";
diff --git a/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/web.xml b/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/web.xml
index 7ae0013fc7..8372cb93a2 100644
--- a/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/web.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/web.xml
@@ -60,6 +60,22 @@
                 </servlet-class>
         <load-on-startup>1</load-on-startup>
     </servlet>
+    <servlet>
+        <servlet-name>CXFServlet4</servlet-name>
+        <display-name>CXF Servlet4</display-name>
+        <servlet-class>
+                        org.apache.cxf.transport.servlet.CXFServlet
+                </servlet-class>
+        <init-param>
+            <param-name>static-resources-list</param-name>
+            <param-value>.*\.html</param-value>
+        </init-param>
+        <init-param>
+            <param-name>redirect-query-check</param-name>
+            <param-value>true</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
     <servlet-mapping>
         <servlet-name>CXFServlet</servlet-name>
         <url-pattern>/the/*</url-pattern>
@@ -72,5 +88,9 @@
         <servlet-name>CXFServlet3</servlet-name>
         <url-pattern>/services/list/*</url-pattern>
     </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>CXFServlet4</servlet-name>
+        <url-pattern>/services/*</url-pattern>
+    </servlet-mapping>
 </web-app>
 <!-- END SNIPPET: webxml -->