Skip to content

Commit a853e94

Browse files
committed
Merge branch '6.2.x'
2 parents f5b5f9a + d80de04 commit a853e94

File tree

8 files changed

+35
-31
lines changed

8 files changed

+35
-31
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ExtendedWebExchangeDataBinder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.web.reactive.result.method.annotation;
1818

1919
import java.util.List;
20+
import java.util.Locale;
2021
import java.util.Map;
2122
import java.util.Set;
2223
import java.util.function.Predicate;
@@ -43,11 +44,11 @@
4344
*/
4445
public class ExtendedWebExchangeDataBinder extends WebExchangeDataBinder {
4546

46-
private static final Set<String> FILTERED_HEADER_NAMES = Set.of("Accept", "Authorization", "Connection",
47-
"Cookie", "From", "Host", "Origin", "Priority", "Range", "Referer", "Upgrade");
47+
private static final Set<String> FILTERED_HEADER_NAMES = Set.of("accept", "authorization", "connection",
48+
"cookie", "from", "host", "origin", "priority", "range", "referer", "upgrade");
4849

4950

50-
private Predicate<String> headerPredicate = name -> !FILTERED_HEADER_NAMES.contains(name);
51+
private Predicate<String> headerPredicate = name -> !FILTERED_HEADER_NAMES.contains(name.toLowerCase(Locale.ROOT));
5152

5253

5354
public ExtendedWebExchangeDataBinder(@Nullable Object target, String objectName) {

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void headerPredicate() throws Exception {
224224

225225
@ParameterizedTest
226226
@ValueSource(strings = {"Accept", "Authorization", "Connection",
227-
"Cookie", "From", "Host", "Origin", "Priority", "Range", "Referer", "Upgrade"})
227+
"Cookie", "From", "Host", "Origin", "Priority", "Range", "Referer", "Upgrade", "priority"})
228228
void filteredHeaders(String headerName) throws Exception {
229229
MockServerHttpRequest request = MockServerHttpRequest.get("/path")
230230
.header(headerName, "u1")

spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import freemarker.template.Configuration;
2929
import org.junit.jupiter.api.BeforeEach;
3030
import org.junit.jupiter.api.Test;
31-
import org.junit.jupiter.api.condition.DisabledForJreRange;
32-
import org.junit.jupiter.api.condition.JRE;
3331
import reactor.core.publisher.Mono;
3432
import reactor.test.StepVerifier;
3533

@@ -125,12 +123,6 @@ private void testMacroOutput(String name, String... contents) throws Exception {
125123

126124
}
127125

128-
@Test
129-
@DisabledForJreRange(min = JRE.JAVA_21)
130-
public void age() throws Exception {
131-
testMacroOutput("AGE", "99");
132-
}
133-
134126
@Test
135127
void message() throws Exception {
136128
testMacroOutput("MESSAGE", "Howdy Mundo");

spring-webflux/src/test/resources/org/springframework/web/reactive/result/view/freemarker/test-macro.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ test template for FreeMarker macro support
66
NAME
77
${command.name}
88

9-
AGE
10-
${command.age}
11-
129
MESSAGE
1310
<@spring.message "hello"/> <@spring.message "world"/>
1411

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.ArrayList;
2020
import java.util.Enumeration;
2121
import java.util.List;
22+
import java.util.Locale;
2223
import java.util.Map;
2324
import java.util.Set;
2425
import java.util.function.Predicate;
@@ -39,7 +40,7 @@
3940
*
4041
* <p><strong>WARNING</strong>: Data binding can lead to security issues by exposing
4142
* parts of the object graph that are not meant to be accessed or modified by
42-
* external clients. Therefore the design and use of data binding should be considered
43+
* external clients. Therefore, the design and use of data binding should be considered
4344
* carefully with regard to security. For more details, please refer to the dedicated
4445
* sections on data binding for
4546
* <a href="https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-ann-initbinder-model-design">Spring Web MVC</a> and
@@ -53,11 +54,11 @@
5354
*/
5455
public class ExtendedServletRequestDataBinder extends ServletRequestDataBinder {
5556

56-
private static final Set<String> FILTERED_HEADER_NAMES = Set.of("Accept", "Authorization", "Connection",
57-
"Cookie", "From", "Host", "Origin", "Priority", "Range", "Referer", "Upgrade");
57+
private static final Set<String> FILTERED_HEADER_NAMES = Set.of("accept", "authorization", "connection",
58+
"cookie", "from", "host", "origin", "priority", "range", "referer", "upgrade");
5859

5960

60-
private Predicate<String> headerPredicate = name -> !FILTERED_HEADER_NAMES.contains(name);
61+
private Predicate<String> headerPredicate = name -> !FILTERED_HEADER_NAMES.contains(name.toLowerCase(Locale.ROOT));
6162

6263

6364
/**

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.beans.MutablePropertyValues;
2828
import org.springframework.beans.testfixture.beans.TestBean;
2929
import org.springframework.core.ResolvableType;
30+
import org.springframework.validation.BindingResult;
3031
import org.springframework.web.bind.ServletRequestDataBinder;
3132
import org.springframework.web.bind.annotation.BindParam;
3233
import org.springframework.web.bind.support.BindParamNameResolver;
@@ -36,7 +37,7 @@
3637
import static org.assertj.core.api.Assertions.assertThat;
3738

3839
/**
39-
* Test fixture for {@link ExtendedServletRequestDataBinder}.
40+
* Tests for {@link ExtendedServletRequestDataBinder}.
4041
*
4142
* @author Rossen Stoyanchev
4243
*/
@@ -136,6 +137,19 @@ void headerPredicateWithConstructorArgs() {
136137
assertThat(bean.someIntArray()).isNull();
137138
}
138139

140+
@Test
141+
void filteredPriorityHeaderForConstructorBinding() {
142+
TestBinder binder = new TestBinder();
143+
binder.setTargetType(ResolvableType.forClass(TestTarget.class));
144+
request.addHeader("Priority", "u1");
145+
146+
binder.construct(request);
147+
BindingResult result = binder.getBindingResult();
148+
TestTarget target = (TestTarget) result.getTarget();
149+
150+
assertThat(target.priority).isNull();
151+
}
152+
139153
@Test
140154
void headerPredicate() {
141155
TestBinder binder = new TestBinder();
@@ -179,4 +193,14 @@ public void addBindValues(MutablePropertyValues mpvs, ServletRequest request) {
179193
}
180194
}
181195

196+
static class TestTarget {
197+
198+
final String priority;
199+
200+
public TestTarget(String priority) {
201+
this.priority = priority;
202+
}
203+
204+
}
205+
182206
}

spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import jakarta.servlet.http.HttpServletResponse;
3232
import org.junit.jupiter.api.BeforeEach;
3333
import org.junit.jupiter.api.Test;
34-
import org.junit.jupiter.api.condition.DisabledForJreRange;
35-
import org.junit.jupiter.api.condition.JRE;
3634

3735
import org.springframework.beans.testfixture.beans.TestBean;
3836
import org.springframework.core.io.ClassPathResource;
@@ -145,12 +143,6 @@ void testName() throws Exception {
145143
assertThat(getMacroOutput("NAME")).isEqualTo("Darren");
146144
}
147145

148-
@Test
149-
@DisabledForJreRange(min = JRE.JAVA_21)
150-
public void testAge() throws Exception {
151-
assertThat(getMacroOutput("AGE")).isEqualTo("99");
152-
}
153-
154146
@Test
155147
void testMessage() throws Exception {
156148
assertThat(getMacroOutput("MESSAGE")).isEqualTo("Howdy Mundo");

spring-webmvc/src/test/resources/org/springframework/web/servlet/view/freemarker/test.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ test template for FreeMarker macro test class
66
NAME
77
${command.name}
88

9-
AGE
10-
${command.age}
11-
129
MESSAGE
1310
<@spring.message "hello"/> <@spring.message "world"/>
1411

0 commit comments

Comments
 (0)