Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit fc6ded7

Browse files
committed
Add project for SPR-12695
1 parent 29d7294 commit fc6ded7

File tree

10 files changed

+447
-0
lines changed

10 files changed

+447
-0
lines changed

SPR-12695/pom.xml

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.springframework.issues</groupId>
5+
<artifactId>SPR-12695</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>Spring MVC Issue Reproduction Project</name>
8+
<packaging>war</packaging>
9+
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
13+
<java.version>1.6</java.version>
14+
<spring.version>4.2.0.BUILD-SNAPSHOT</spring.version>
15+
<slf4j.version>1.7.5</slf4j.version>
16+
17+
<jetty.version>9.1.2.v20140210</jetty.version>
18+
<cargo.container.id>tomcat7x</cargo.container.id>
19+
<cargo.container.url>
20+
http://www.eu.apache.org/dist/tomcat/tomcat-7/v7.0.52/bin/apache-tomcat-7.0.52.zip
21+
</cargo.container.url>
22+
</properties>
23+
24+
<dependencies>
25+
<!-- Spring Framework -->
26+
<dependency>
27+
<groupId>org.springframework</groupId>
28+
<artifactId>spring-context</artifactId>
29+
<version>${spring.version}</version>
30+
<exclusions>
31+
<!-- Exclude Commons Logging in favor of SLF4j -->
32+
<exclusion>
33+
<groupId>commons-logging</groupId>
34+
<artifactId>commons-logging</artifactId>
35+
</exclusion>
36+
</exclusions>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework</groupId>
40+
<artifactId>spring-webmvc</artifactId>
41+
<version>${spring.version}</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.springframework</groupId>
45+
<artifactId>spring-context-support</artifactId>
46+
<version>${spring.version}</version>
47+
</dependency>
48+
49+
<!-- CGLIB, required for @Configuration usage -->
50+
<dependency>
51+
<groupId>cglib</groupId>
52+
<artifactId>cglib-nodep</artifactId>
53+
<version>2.2</version>
54+
</dependency>
55+
56+
<!-- Logging -->
57+
<dependency>
58+
<groupId>org.slf4j</groupId>
59+
<artifactId>slf4j-api</artifactId>
60+
<version>${slf4j.version}</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.slf4j</groupId>
64+
<artifactId>jcl-over-slf4j</artifactId>
65+
<version>${slf4j.version}</version>
66+
<scope>runtime</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.slf4j</groupId>
70+
<artifactId>slf4j-log4j12</artifactId>
71+
<version>${slf4j.version}</version>
72+
<scope>runtime</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>log4j</groupId>
76+
<artifactId>log4j</artifactId>
77+
<version>1.2.17</version>
78+
<scope>runtime</scope>
79+
</dependency>
80+
81+
<!-- Servlet API -->
82+
<dependency>
83+
<groupId>javax.servlet</groupId>
84+
<artifactId>servlet-api</artifactId>
85+
<version>2.5</version>
86+
<scope>provided</scope>
87+
</dependency>
88+
89+
90+
<!-- JSP API and JSTL
91+
<dependency>
92+
<groupId>javax.servlet.jsp</groupId>
93+
<artifactId>jsp-api</artifactId>
94+
<version>2.1</version>
95+
<scope>provided</scope>
96+
</dependency>-->
97+
<dependency>
98+
<groupId>javax.servlet</groupId>
99+
<artifactId>jstl</artifactId>
100+
<version>1.2</version>
101+
</dependency>
102+
103+
104+
<dependency>
105+
<groupId>org.freemarker</groupId>
106+
<artifactId>freemarker</artifactId>
107+
<version>2.3.20</version>
108+
</dependency>
109+
110+
<dependency>
111+
<groupId>org.apache.velocity</groupId>
112+
<artifactId>velocity</artifactId>
113+
<version>1.7</version>
114+
</dependency>
115+
<dependency>
116+
<groupId>org.apache.velocity</groupId>
117+
<artifactId>velocity-tools</artifactId>
118+
<version>2.0</version>
119+
</dependency>
120+
121+
<dependency>
122+
<groupId>org.apache.tiles</groupId>
123+
<artifactId>tiles-extras</artifactId>
124+
<version>3.0.3</version>
125+
</dependency>
126+
127+
<dependency>
128+
<groupId>com.fasterxml.jackson.core</groupId>
129+
<artifactId>jackson-databind</artifactId>
130+
<version>2.4.1</version>
131+
</dependency>
132+
<dependency>
133+
<groupId>com.fasterxml.jackson.core</groupId>
134+
<artifactId>jackson-core</artifactId>
135+
<version>2.4.1</version>
136+
</dependency>
137+
138+
<!-- Test -->
139+
<dependency>
140+
<groupId>junit</groupId>
141+
<artifactId>junit</artifactId>
142+
<version>4.11</version>
143+
<scope>test</scope>
144+
</dependency>
145+
</dependencies>
146+
147+
<build>
148+
<plugins>
149+
<plugin>
150+
<groupId>org.apache.maven.plugins</groupId>
151+
<artifactId>maven-compiler-plugin</artifactId>
152+
<version>2.5.1</version>
153+
<configuration>
154+
<source>${java.version}</source>
155+
<target>${java.version}</target>
156+
</configuration>
157+
</plugin>
158+
<plugin>
159+
<groupId>org.apache.maven.plugins</groupId>
160+
<artifactId>maven-dependency-plugin</artifactId>
161+
<version>2.8</version>
162+
<executions>
163+
<execution>
164+
<id>install</id>
165+
<phase>install</phase>
166+
<goals>
167+
<goal>sources</goal>
168+
</goals>
169+
</execution>
170+
</executions>
171+
</plugin>
172+
<plugin>
173+
<groupId>org.apache.maven.plugins</groupId>
174+
<artifactId>maven-eclipse-plugin</artifactId>
175+
<version>2.8</version>
176+
<configuration>
177+
<downloadSources>true</downloadSources>
178+
<downloadJavadocs>false</downloadJavadocs>
179+
<wtpversion>2.0</wtpversion>
180+
</configuration>
181+
</plugin>
182+
<plugin>
183+
<groupId>org.apache.maven.plugins</groupId>
184+
<artifactId>maven-surefire-plugin</artifactId>
185+
<version>2.12.4</version>
186+
<configuration>
187+
<includes>
188+
<include>**/*Tests.java</include>
189+
<include>**/*Test.java</include>
190+
</includes>
191+
<excludes>
192+
<exclude>**/*Abstract*.java</exclude>
193+
</excludes>
194+
</configuration>
195+
</plugin>
196+
<plugin>
197+
<groupId>org.eclipse.jetty</groupId>
198+
<artifactId>jetty-maven-plugin</artifactId>
199+
<version>${jetty.version}</version>
200+
</plugin>
201+
<plugin>
202+
<groupId>org.codehaus.cargo</groupId>
203+
<artifactId>cargo-maven2-plugin</artifactId>
204+
<version>1.4.7</version>
205+
<configuration>
206+
<configuration>
207+
<properties>
208+
<cargo.servlet.port>8080</cargo.servlet.port>
209+
<cargo.tomcat.ajp.port>1099</cargo.tomcat.ajp.port>
210+
<cargo.rmi.port>1099</cargo.rmi.port>
211+
<cargo.logging>medium</cargo.logging>
212+
<cargo.jvmargs>-Xms96m -Xmx512m -Djava.awt.headless=true</cargo.jvmargs>
213+
</properties>
214+
</configuration>
215+
<container>
216+
<containerId>${cargo.container.id}</containerId>
217+
<zipUrlInstaller>
218+
<url>${cargo.container.url}</url>
219+
</zipUrlInstaller>
220+
</container>
221+
</configuration>
222+
</plugin>
223+
</plugins>
224+
</build>
225+
226+
<profiles>
227+
<profile>
228+
<id>tomcat8</id>
229+
<properties>
230+
<cargo.container.id>tomcat8x</cargo.container.id>
231+
<cargo.container.url>
232+
http://www.eu.apache.org/dist/tomcat/tomcat-8/v8.0.3/bin/apache-tomcat-8.0.3.zip
233+
</cargo.container.url>
234+
</properties>
235+
</profile>
236+
<profile>
237+
<id>jetty8</id>
238+
<build>
239+
<plugins>
240+
<plugin>
241+
<groupId>org.codehaus.cargo</groupId>
242+
<artifactId>cargo-maven2-plugin</artifactId>
243+
<configuration>
244+
<container>
245+
<containerId>jetty8x</containerId>
246+
<type>embedded</type>
247+
</container>
248+
</configuration>
249+
</plugin>
250+
</plugins>
251+
</build>
252+
</profile>
253+
</profiles>
254+
255+
<repositories>
256+
<repository>
257+
<id>spring-maven-snapshot</id>
258+
<name>Springframework Maven Snapshot Repository</name>
259+
<url>http://repo.spring.io/snapshot</url>
260+
<snapshots>
261+
<enabled>true</enabled>
262+
</snapshots>
263+
</repository>
264+
</repositories>
265+
266+
</project>
267+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2002-2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.issues;
18+
19+
import org.springframework.stereotype.Controller;
20+
import org.springframework.ui.ModelMap;
21+
import org.springframework.validation.BindingResult;
22+
import org.springframework.web.bind.annotation.ModelAttribute;
23+
import org.springframework.web.bind.annotation.RequestMapping;
24+
import org.springframework.web.bind.annotation.RequestMethod;
25+
26+
@Controller
27+
public class TestController {
28+
29+
30+
@RequestMapping(value = "/test", method = RequestMethod.GET)
31+
public String handleGet(ModelMap model) {
32+
model.addAttribute("command", new TestEntity());
33+
return null;
34+
}
35+
36+
@RequestMapping(value = "/test", method = RequestMethod.POST)
37+
public String handlePost(@ModelAttribute("command") TestEntity testEntity, BindingResult result) {
38+
result.rejectValue("name", null, "lat=<img onerror=\"alert(String.fromCharCode(120,115,115))\" src=\"#\">");
39+
return "test";
40+
}
41+
42+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2002-2015 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.issues;
17+
18+
19+
public class TestEntity {
20+
21+
private String name;
22+
23+
24+
public String getName() {
25+
return name;
26+
}
27+
28+
public void setName(String name) {
29+
this.name = name;
30+
}
31+
32+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.springframework.issues.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.ComponentScan;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7+
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
8+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
9+
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
10+
11+
12+
@EnableWebMvc
13+
@ComponentScan(basePackages="org.springframework.issues")
14+
@Configuration
15+
public class WebConfig extends WebMvcConfigurerAdapter {
16+
17+
18+
@Override
19+
public void configureViewResolvers(ViewResolverRegistry registry) {
20+
registry.freeMarker().suffix(".ftl");
21+
}
22+
23+
@Bean
24+
public FreeMarkerConfigurer freeMarkerConfigurer() {
25+
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
26+
configurer.setTemplateLoaderPath("classpath:/templates/");
27+
return configurer;
28+
}
29+
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
log4j.rootCategory=DEBUG, stdout
2+
3+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5+
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
6+
7+
log4j.category.org.springframework.web=DEBUG
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<#import "/spring.ftl" as spring />
2+
<html>
3+
<form action="" method="POST">
4+
Name:
5+
<@spring.formInput "command.name"/>
6+
<@spring.showErrors "<br>"/>
7+
<input type="submit" value="submit"/>
8+
</form>
9+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
<body>
3+
${model.hello}
4+
</body>
5+
</html>

0 commit comments

Comments
 (0)