Skip to content

Commit 774231d

Browse files
committed
Merge branch '6.2.x'
2 parents e8788c7 + c971276 commit 774231d

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,8 @@
4343
*/
4444
public class ExtendedWebExchangeDataBinder extends WebExchangeDataBinder {
4545

46-
private static final Set<String> FILTERED_HEADER_NAMES = Set.of("Priority");
46+
private static final Set<String> FILTERED_HEADER_NAMES = Set.of("Accept", "Authorization", "Connection",
47+
"Cookie", "From", "Host", "Origin", "Priority", "Range", "Referer", "Upgrade");
4748

4849

4950
private Predicate<String> headerPredicate = name -> !FILTERED_HEADER_NAMES.contains(name);

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,8 @@
2323
import java.util.Map;
2424

2525
import org.junit.jupiter.api.Test;
26+
import org.junit.jupiter.params.ParameterizedTest;
27+
import org.junit.jupiter.params.provider.ValueSource;
2628

2729
import org.springframework.beans.testfixture.beans.TestBean;
2830
import org.springframework.core.DefaultParameterNameDiscoverer;
@@ -220,6 +222,23 @@ void headerPredicate() throws Exception {
220222
assertThat(map).containsExactlyInAnyOrderEntriesOf(Map.of("someIntArray", "1", "Some-Int-Array", "1"));
221223
}
222224

225+
@ParameterizedTest
226+
@ValueSource(strings = {"Accept", "Authorization", "Connection",
227+
"Cookie", "From", "Host", "Origin", "Priority", "Range", "Referer", "Upgrade"})
228+
void filteredHeaders(String headerName) throws Exception {
229+
MockServerHttpRequest request = MockServerHttpRequest.get("/path")
230+
.header(headerName, "u1")
231+
.build();
232+
233+
MockServerWebExchange exchange = MockServerWebExchange.from(request);
234+
235+
BindingContext context = createBindingContext("initBinderWithAttributeName", WebDataBinder.class);
236+
ExtendedWebExchangeDataBinder binder = (ExtendedWebExchangeDataBinder) context.createDataBinder(exchange, null, "", null);
237+
238+
Map<String, Object> map = binder.getValuesToBind(exchange).block();
239+
assertThat(map).isEmpty();
240+
}
241+
223242
private BindingContext createBindingContext(String methodName, Class<?>... parameterTypes) throws Exception {
224243
Object handler = new InitBinderHandler();
225244
Method method = handler.getClass().getMethod(methodName, parameterTypes);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,7 +53,8 @@
5353
*/
5454
public class ExtendedServletRequestDataBinder extends ServletRequestDataBinder {
5555

56-
private static final Set<String> FILTERED_HEADER_NAMES = Set.of("Priority");
56+
private static final Set<String> FILTERED_HEADER_NAMES = Set.of("Accept", "Authorization", "Connection",
57+
"Cookie", "From", "Host", "Origin", "Priority", "Range", "Referer", "Upgrade");
5758

5859

5960
private Predicate<String> headerPredicate = name -> !FILTERED_HEADER_NAMES.contains(name);

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
2121
import jakarta.servlet.ServletRequest;
2222
import org.junit.jupiter.api.BeforeEach;
2323
import org.junit.jupiter.api.Test;
24+
import org.junit.jupiter.params.ParameterizedTest;
25+
import org.junit.jupiter.params.provider.ValueSource;
2426

2527
import org.springframework.beans.MutablePropertyValues;
2628
import org.springframework.beans.testfixture.beans.TestBean;
@@ -104,6 +106,19 @@ void uriVarsAndHeadersAddedConditionally() {
104106
assertThat(target.getAge()).isEqualTo(25);
105107
}
106108

109+
@ParameterizedTest
110+
@ValueSource(strings = {"Accept", "Authorization", "Connection",
111+
"Cookie", "From", "Host", "Origin", "Priority", "Range", "Referer", "Upgrade"})
112+
void filteredHeaders(String headerName) {
113+
TestBinder binder = new TestBinder();
114+
115+
MutablePropertyValues mpvs = new MutablePropertyValues();
116+
request.addHeader(headerName, "u1");
117+
binder.addBindValues(mpvs, request);
118+
119+
assertThat(mpvs).isEmpty();
120+
}
121+
107122
@Test
108123
void headerPredicate() {
109124
TestBinder binder = new TestBinder();

0 commit comments

Comments
 (0)