Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
* @author Artsiom Yudovin
* @author Andrew McGhie
* @author Rafiullah Hamedy
* @author Dirk Deyne
* @since 1.0.0
*/
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
Expand Down Expand Up @@ -405,6 +406,20 @@ public static class Tomcat {
*/
private final Mbeanregistry mbeanregistry = new Mbeanregistry();

/**
* Specify additional unencoded characters that Tomcat should allow in a
* querystring. The value may be any combination of the following characters: " <
* > [ \ ] ^ ` { | } . Any other characters present in the value will be ignored.
*/
private String relaxedQueryChars;

/**
* Specify additional unencoded characters that Tomcat should allow in the path.
* The value may be any combination of the following characters: " < > [ \ ] ^ ` {
* | } . Any other characters present in the value will be ignored.
*/
private String relaxedPathChars;

public int getMaxThreads() {
return this.maxThreads;
}
Expand Down Expand Up @@ -561,6 +576,22 @@ public Mbeanregistry getMbeanregistry() {
return this.mbeanregistry;
}

public String getRelaxedPathChars() {
return this.relaxedPathChars;
}

public void setRelaxedPathChars(String relaxedPathChars) {
this.relaxedPathChars = relaxedPathChars;
}

public String getRelaxedQueryChars() {
return this.relaxedQueryChars;
}

public void setRelaxedQueryChars(String relaxedQueryChars) {
this.relaxedQueryChars = relaxedQueryChars;
}

/**
* Tomcat access log properties.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
* @author Artsiom Yudovin
* @author Chentao Qu
* @author Andrew McGhie
* @author Dirk Deyne
* @since 2.0.0
*/
public class TomcatWebServerFactoryCustomizer
Expand Down Expand Up @@ -102,6 +103,10 @@ public void customize(ConfigurableTomcatWebServerFactory factory) {
.to((acceptCount) -> customizeAcceptCount(factory, acceptCount));
propertyMapper.from(tomcatProperties::getProcessorCache)
.to((processorCache) -> customizeProcessorCache(factory, processorCache));
propertyMapper.from(tomcatProperties::getRelaxedQueryChars)
.to((relaxedChars) -> customizeRelaxedQueryChars(factory, relaxedChars));
propertyMapper.from(tomcatProperties::getRelaxedPathChars)
.to((relaxedChars) -> customizeRelaxedPathChars(factory, relaxedChars));
customizeStaticResources(factory);
customizeErrorReportValve(properties.getError(), factory);
}
Expand Down Expand Up @@ -149,6 +154,14 @@ private void customizeConnectionTimeout(ConfigurableTomcatWebServerFactory facto
});
}

private void customizeRelaxedQueryChars(ConfigurableTomcatWebServerFactory factory, String relaxedChars) {
factory.addConnectorCustomizers((connector) -> connector.setAttribute("relaxedQueryChars", relaxedChars));
}

private void customizeRelaxedPathChars(ConfigurableTomcatWebServerFactory factory, String relaxedChars) {
factory.addConnectorCustomizers((connector) -> connector.setAttribute("relaxedPathChars", relaxedChars));
}

private void customizeRemoteIpValve(ConfigurableTomcatWebServerFactory factory) {
Tomcat tomcatProperties = this.serverProperties.getTomcat();
String protocolHeader = tomcatProperties.getProtocolHeader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ void testTomcatBinding() {
map.put("server.tomcat.remote-ip-header", "Remote-Ip");
map.put("server.tomcat.internal-proxies", "10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
map.put("server.tomcat.background-processor-delay", "10");
map.put("server.tomcat.relaxed-path-chars", "|");
map.put("server.tomcat.relaxed-query-chars", "^^");
bind(map);
ServerProperties.Tomcat tomcat = this.properties.getTomcat();
Accesslog accesslog = tomcat.getAccesslog();
Expand All @@ -146,6 +148,8 @@ void testTomcatBinding() {
assertThat(tomcat.getProtocolHeader()).isEqualTo("X-Forwarded-Protocol");
assertThat(tomcat.getInternalProxies()).isEqualTo("10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
assertThat(tomcat.getBackgroundProcessorDelay()).isEqualTo(Duration.ofSeconds(10));
assertThat(tomcat.getRelaxedPathChars()).isEqualTo("|");
assertThat(tomcat.getRelaxedQueryChars()).isEqualTo("^^");
}

@Test
Expand Down