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:
Rossen Stoyanchev
2018-02-02 15:17:58 -05:00
parent b708027e94
commit fe4472dbeb
2 changed files with 22 additions and 9 deletions

View File

@@ -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]");