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

matrei pushed a commit to branch fix/issue-16145
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 89c2e31612299022afcaba3390c82019acb7f871
Author: Mattias Reichel <[email protected]>
AuthorDate: Thu Aug 13 13:34:28 2026 +0200

    test: reproduce issue 16145
---
 .../ControllersAutoConfigurationSpec.groovy          | 12 ++++++++++++
 .../web/filters/HiddenHttpMethodFilterTests.groovy   | 20 +++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git 
a/grails-controllers/src/test/groovy/org/grails/plugins/web/controllers/ControllersAutoConfigurationSpec.groovy
 
b/grails-controllers/src/test/groovy/org/grails/plugins/web/controllers/ControllersAutoConfigurationSpec.groovy
index 1d2c17b61f..f55a956a01 100644
--- 
a/grails-controllers/src/test/groovy/org/grails/plugins/web/controllers/ControllersAutoConfigurationSpec.groovy
+++ 
b/grails-controllers/src/test/groovy/org/grails/plugins/web/controllers/ControllersAutoConfigurationSpec.groovy
@@ -21,6 +21,8 @@ package org.grails.plugins.web.controllers
 
 import java.util.function.Supplier
 
+import jakarta.servlet.Filter
+
 import grails.core.DefaultGrailsApplication
 import grails.core.GrailsApplication
 
@@ -38,6 +40,7 @@ import org.springframework.mock.web.MockServletContext
 import org.springframework.web.context.WebApplicationContext
 import org.springframework.web.context.support.StaticWebApplicationContext
 import org.springframework.web.filter.RequestContextFilter
+import org.springframework.web.multipart.support.MultipartFilter
 import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
 
 import org.grails.web.config.http.GrailsFilters
@@ -75,6 +78,15 @@ class ControllersAutoConfigurationSpec extends Specification 
{
         registrationBean.order == GrailsFilters.GRAILS_WEB_REQUEST_FILTER.order
     }
 
+    void 'multipartFilter registers before the other Grails filters'() {
+        when: 'the multipart filter is created'
+        def registrationBean = autoConfiguration.multipartFilter()
+
+        then: 'it is registered at the first Grails filter order'
+        registrationBean.filter instanceof MultipartFilter
+        registrationBean.order == GrailsFilters.FIRST.order
+    }
+
     void 'Boot WebMvcAutoConfiguration registers its own requestContextFilter 
when the Grails controllers auto-config is absent'() {
         expect: 'the contrast case proves the backoff assertion below is 
meaningful'
         new WebApplicationContextRunner()
diff --git 
a/grails-test-suite-uber/src/test/groovy/org/grails/web/filters/HiddenHttpMethodFilterTests.groovy
 
b/grails-test-suite-uber/src/test/groovy/org/grails/web/filters/HiddenHttpMethodFilterTests.groovy
index 739dbcf963..e2c9cf9c8d 100644
--- 
a/grails-test-suite-uber/src/test/groovy/org/grails/web/filters/HiddenHttpMethodFilterTests.groovy
+++ 
b/grails-test-suite-uber/src/test/groovy/org/grails/web/filters/HiddenHttpMethodFilterTests.groovy
@@ -18,7 +18,6 @@
  */
 package org.grails.web.filters
 
-import org.grails.web.filters.HiddenHttpMethodFilter
 import org.junit.jupiter.api.Test
 import org.springframework.mock.web.MockHttpServletRequest
 import org.springframework.mock.web.MockHttpServletResponse
@@ -71,4 +70,23 @@ class HiddenHttpMethodFilterTests {
 
         assertEquals "DELETE", method
     }
+
+    @Test
+    void testMultipartRequestDoesNotParseParameters() {
+        def filter = new HiddenHttpMethodFilter()
+        def req = new MockHttpServletRequest() {
+            @Override
+            String getParameter(String name) {
+                throw new IllegalStateException('Multipart request parameters 
must not be parsed by this filter')
+            }
+        }
+        req.contentType = 'multipart/form-data; boundary=test'
+        req.method = 'POST'
+        def res = new MockHttpServletResponse()
+        String method = null
+
+        filter.doFilter(req, res, { req2, res2 -> method = req2.method } as 
FilterChain)
+
+        assertEquals('POST', method)
+    }
 }

Reply via email to