MockMvcRequestBuilder does not decode pathInfo [SPR-16453] #20998
Labels
in: test
Issues in the test module
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Rob Winch opened SPR-16453 and commented
Description
The
HttpServletRequest.getPathInfo()
javadoc states:However,
MockMvcRequestBuilder
does not decodepathInfo
when calculating it from the provided URL. For example, the following test fails, but should passImpact
This bug has a fairly significant impact now that Spring Security rejects request that appear to be performing double encoding. For example, running the test with Spring Security would result in the following exception:
Work Around
A workaround is by using a
RequestPostProcessor
to decode the pathInfo. For example:Then using it like this:
Affects: 4.3.14, 5.0.3
Referenced from: pull request #1659, and commits fe4472d, 0cd427b
Backported to: 4.3.15
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: