Reinstate removal of jsessionid from lookup path

Closes gh-25864
This commit is contained in:
Rossen Stoyanchev
2020-10-07 11:31:52 +01:00
parent ca7fb23432
commit eb11c6fa23
4 changed files with 54 additions and 4 deletions

View File

@@ -389,6 +389,7 @@ public class RequestResponseBodyMethodProcessorTests {
assertContentDisposition(processor, true, "/hello.json;a=b;setup.dataless", "unknown ext in path params");
assertContentDisposition(processor, true, "/hello.dataless;a=b;setup.json", "unknown ext in filename");
assertContentDisposition(processor, false, "/hello.json;a=b;setup.json", "safe extensions");
assertContentDisposition(processor, true, "/hello.json;jsessionid=foo.bar", "jsessionid shouldn't cause issue");
// encoded dot
assertContentDisposition(processor, true, "/hello%2Edataless;a=b;setup.json", "encoded dot in filename");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@@ -69,6 +69,28 @@ public class UriTemplateServletAnnotationControllerHandlerMethodTests extends Ab
assertThat(response.getContentAsString()).isEqualTo("test-42-7");
}
@Test // gh-25864
public void literalMappingWithPathParams() throws Exception {
initServletWithControllers(MultipleUriTemplateController.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/data");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).isEqualTo("test");
request = new MockHttpServletRequest("GET", "/data;foo=bar");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getStatus()).isEqualTo(404);
request = new MockHttpServletRequest("GET", "/data;jsessionid=123");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).isEqualTo("test");
}
@Test
public void multiple() throws Exception {
initServletWithControllers(MultipleUriTemplateController.class);
@@ -388,6 +410,10 @@ public class UriTemplateServletAnnotationControllerHandlerMethodTests extends Ab
writer.write("test-" + hotel + "-q" + qHotel + "-" + booking + "-" + other + "-q" + qOther);
}
@RequestMapping("/data")
void handleWithLiteralMapping(Writer writer) throws IOException {
writer.write("test");
}
}
@Controller