Avoid double encoding URI in ServletServerHttpRequest

Issue: SPR-13876
This commit is contained in:
Rossen Stoyanchev
2016-01-20 17:57:56 -05:00
parent 29692fcc21
commit ab16adab2e
2 changed files with 22 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -64,6 +64,20 @@ public class ServletServerHttpRequestTests {
assertEquals("Invalid uri", uri, request.getURI());
}
// SPR-13876
@Test
public void getUriWithEncoding() throws Exception {
URI uri = new URI("https://example.com/%E4%B8%AD%E6%96%87" +
"?redirect=https%3A%2F%2Fgithub.com%2Fspring-projects%2Fspring-framework");
mockRequest.setScheme(uri.getScheme());
mockRequest.setServerName(uri.getHost());
mockRequest.setServerPort(uri.getPort());
mockRequest.setRequestURI(uri.getRawPath());
mockRequest.setQueryString(uri.getRawQuery());
assertEquals("Invalid uri", uri, request.getURI());
}
@Test
public void getHeaders() throws Exception {
String headerName = "MyHeader";