|
|
|
@ -16,6 +16,10 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.web;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
|
|
|
|
|
|
import java.lang.annotation.Documented;
|
|
|
|
|
import java.lang.annotation.ElementType;
|
|
|
|
|
import java.lang.annotation.Retention;
|
|
|
|
@ -41,10 +45,6 @@ import org.springframework.test.web.servlet.MvcResult;
|
|
|
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
|
|
|
import org.springframework.web.context.WebApplicationContext;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Dave Syer
|
|
|
|
|
*/
|
|
|
|
@ -74,6 +74,22 @@ public class DefaultErrorViewIntegrationTests {
|
|
|
|
|
assertTrue("Wrong content: " + content, content.contains("999"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testErrorWithEscape() throws Exception {
|
|
|
|
|
MvcResult response = this.mockMvc
|
|
|
|
|
.perform(
|
|
|
|
|
get("/error").requestAttr(
|
|
|
|
|
"javax.servlet.error.exception",
|
|
|
|
|
new RuntimeException(
|
|
|
|
|
"<script>alert('Hello World')</script>")).accept(
|
|
|
|
|
MediaType.TEXT_HTML)).andExpect(status().isOk())
|
|
|
|
|
.andReturn();
|
|
|
|
|
String content = response.getResponse().getContentAsString();
|
|
|
|
|
assertTrue("Wrong content: " + content, content.contains("<script>"));
|
|
|
|
|
assertTrue("Wrong content: " + content, content.contains("Hello World"));
|
|
|
|
|
assertTrue("Wrong content: " + content, content.contains("999"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Target(ElementType.TYPE)
|
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
|
|
|
@Documented
|
|
|
|
|