Skip to content

Commit c40e9f4

Browse files
committed
Upgrade to Undertow 2.3.4.Final
Closes gh-34304
1 parent 6e2be8b commit c40e9f4

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,10 +1534,19 @@ public static class Undertow {
15341534
* Whether the server should decode percent encoded slash characters. Enabling
15351535
* encoded slashes can have security implications due to different servers
15361536
* interpreting the slash differently. Only enable this if you have a legacy
1537-
* application that requires it.
1537+
* application that requires it. Has no effect when server.undertow.decode-slash
1538+
* is set.
15381539
*/
15391540
private boolean allowEncodedSlash = false;
15401541

1542+
/**
1543+
* Whether encoded slash characters (%2F) should be decoded. Decoding can cause
1544+
* security problems if a front-end proxy does not perform the same decoding. Only
1545+
* enable this if you have a legacy application that requires it. When set,
1546+
* server.undertow.allow-encoded-slash has no effect.
1547+
*/
1548+
private Boolean decodeSlash;
1549+
15411550
/**
15421551
* Whether the URL should be decoded. When disabled, percent-encoded characters in
15431552
* the URL will be left as-is.
@@ -1631,14 +1640,25 @@ public void setMaxCookies(Integer maxCookies) {
16311640
this.maxCookies = maxCookies;
16321641
}
16331642

1643+
@DeprecatedConfigurationProperty(replacement = "server.undertow.decode-slash")
1644+
@Deprecated(forRemoval = true, since = "3.0.3")
16341645
public boolean isAllowEncodedSlash() {
16351646
return this.allowEncodedSlash;
16361647
}
16371648

1649+
@Deprecated(forRemoval = true, since = "3.0.3")
16381650
public void setAllowEncodedSlash(boolean allowEncodedSlash) {
16391651
this.allowEncodedSlash = allowEncodedSlash;
16401652
}
16411653

1654+
public Boolean getDecodeSlash() {
1655+
return this.decodeSlash;
1656+
}
1657+
1658+
public void setDecodeSlash(Boolean decodeSlash) {
1659+
this.decodeSlash = decodeSlash;
1660+
}
1661+
16421662
public boolean isDecodeUrl() {
16431663
return this.decodeUrl;
16441664
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -98,7 +98,7 @@ private void mapUndertowProperties(ConfigurableUndertowWebServerFactory factory,
9898
map.from(properties::getMaxParameters).to(serverOptions.option(UndertowOptions.MAX_PARAMETERS));
9999
map.from(properties::getMaxHeaders).to(serverOptions.option(UndertowOptions.MAX_HEADERS));
100100
map.from(properties::getMaxCookies).to(serverOptions.option(UndertowOptions.MAX_COOKIES));
101-
map.from(properties::isAllowEncodedSlash).to(serverOptions.option(UndertowOptions.ALLOW_ENCODED_SLASH));
101+
mapSlashProperties(properties, serverOptions);
102102
map.from(properties::isDecodeUrl).to(serverOptions.option(UndertowOptions.DECODE_URL));
103103
map.from(properties::getUrlCharset).as(Charset::name).to(serverOptions.option(UndertowOptions.URL_CHARSET));
104104
map.from(properties::isAlwaysSetKeepAlive).to(serverOptions.option(UndertowOptions.ALWAYS_SET_KEEP_ALIVE));
@@ -109,6 +109,14 @@ private void mapUndertowProperties(ConfigurableUndertowWebServerFactory factory,
109109
map.from(properties.getOptions()::getSocket).to(socketOptions.forEach(socketOptions::option));
110110
}
111111

112+
@SuppressWarnings({ "deprecation", "removal" })
113+
private void mapSlashProperties(Undertow properties, ServerOptions serverOptions) {
114+
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
115+
map.from(properties::isAllowEncodedSlash).to(serverOptions.option(UndertowOptions.ALLOW_ENCODED_SLASH));
116+
map.from(properties::getDecodeSlash).to(serverOptions.option(UndertowOptions.DECODE_SLASH));
117+
118+
}
119+
112120
private boolean isPositive(Number value) {
113121
return value.longValue() > 0;
114122
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -150,11 +150,18 @@ void customizeWorkerThreads() {
150150
}
151151

152152
@Test
153+
@Deprecated(forRemoval = true, since = "3.0.3")
153154
void allowEncodedSlashes() {
154155
bind("server.undertow.allow-encoded-slash=true");
155156
assertThat(boundServerOption(UndertowOptions.ALLOW_ENCODED_SLASH)).isTrue();
156157
}
157158

159+
@Test
160+
void enableSlashDecoding() {
161+
bind("server.undertow.decode-slash=true");
162+
assertThat(boundServerOption(UndertowOptions.DECODE_SLASH)).isTrue();
163+
}
164+
158165
@Test
159166
void disableUrlDecoding() {
160167
bind("server.undertow.decode-url=false");

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ bom {
14891489
]
14901490
}
14911491
}
1492-
library("Undertow", "2.3.3.Final") {
1492+
library("Undertow", "2.3.4.Final") {
14931493
group("io.undertow") {
14941494
modules = [
14951495
"undertow-core",

0 commit comments

Comments
 (0)