SEC-3082: make SavedRequest parameters case sensitive

This commit is contained in:
Rob Winch 2015-10-29 16:36:20 -05:00
parent 0981cd975f
commit 4144de9376
2 changed files with 6 additions and 5 deletions

View File

@ -62,8 +62,7 @@ public class DefaultSavedRequest implements SavedRequest {
private final ArrayList<Locale> locales = new ArrayList<Locale>(); private final ArrayList<Locale> locales = new ArrayList<Locale>();
private final Map<String, List<String>> headers = new TreeMap<String, List<String>>( private final Map<String, List<String>> headers = new TreeMap<String, List<String>>(
String.CASE_INSENSITIVE_ORDER); String.CASE_INSENSITIVE_ORDER);
private final Map<String, String[]> parameters = new TreeMap<String, String[]>( private final Map<String, String[]> parameters = new TreeMap<String, String[]>();
String.CASE_INSENSITIVE_ORDER);
private final String contextPath; private final String contextPath;
private final String method; private final String method;
private final String pathInfo; private final String pathInfo;

View File

@ -32,13 +32,15 @@ public class DefaultSavedRequestTests {
assertTrue(saved.getHeaderValues("if-none-match").isEmpty()); assertTrue(saved.getHeaderValues("if-none-match").isEmpty());
} }
// TODO: Why are parameters case insensitive. I think this is a mistake // SEC-3082
@Test @Test
public void parametersAreCaseInsensitive() throws Exception { public void parametersAreCaseSensitive() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("ThisIsATest", "Hi mom"); request.addParameter("AnotHerTest", "Hi dad");
request.addParameter("thisisatest", "Hi mom");
DefaultSavedRequest saved = new DefaultSavedRequest(request, DefaultSavedRequest saved = new DefaultSavedRequest(request,
new MockPortResolver(8080, 8443)); new MockPortResolver(8080, 8443));
assertEquals("Hi mom", saved.getParameterValues("thisisatest")[0]); assertEquals("Hi mom", saved.getParameterValues("thisisatest")[0]);
assertNull(saved.getParameterValues("anothertest"));
} }
} }