MockHttpServletRequestBuilder decodes pathInfo
Previously MockHttpServletRequestBuilder calculated the pathInfo from the provided URL without decoding the value. This meant that the pathInfo incorrectly included URL encoded values. Now MockHttpServletRequestBuilder properly decodes the pathInfo. Backport of #0cd427bdd35e668dda6332ae2885d94c222d9c49. Fixes: SPR-16453
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -163,6 +163,14 @@ public class MockHttpServletRequestBuilderTests {
|
||||
assertNull(request.getPathInfo());
|
||||
}
|
||||
|
||||
@Test // SPR-16453
|
||||
public void pathInfoIsDecoded() {
|
||||
this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/travel/hotels 42");
|
||||
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
|
||||
|
||||
assertEquals("/travel/hotels 42", request.getPathInfo());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contextPathServletPathInvalid() {
|
||||
testContextPathServletPathInvalid("/Foo", "", "Request URI [/foo/bar] does not start with context path [/Foo]");
|
||||
|
||||
Reference in New Issue
Block a user