Skip to content

Commit 34e62bb

Browse files
committed
Reinstate permissive alias check
Without the permissive check, unusually named static resources are inaccessible. The need for this may be due to a Jetty bug. This change restores the tests to their previous form for now. See gh-40568
1 parent f70a270 commit 34e62bb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/spring-boot-server-tests-app/src/main/java/com/example/JettyServerCustomizerConfig.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -20,6 +20,7 @@
2020
import org.eclipse.jetty.server.AllowedResourceAliasChecker;
2121
import org.eclipse.jetty.server.Connector;
2222
import org.eclipse.jetty.server.HttpConnectionFactory;
23+
import org.eclipse.jetty.server.handler.ContextHandler;
2324

2425
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2526
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
@@ -29,19 +30,23 @@
2930
/**
3031
* {@link JettyServerCustomizer} that:
3132
* <ul>
33+
* <li>Approves all aliases to allow access to unusually named static resources
3234
* <li>Relaxes URI compliance to allow access to static resources with {@code %} in their file name.
3335
* </ul>
3436
*
3537
* @author Madhura Bhave
3638
* @author Andy Wilkinson
3739
*/
38-
@ConditionalOnClass(name = "org.eclipse.jetty.server.Connector")
40+
@ConditionalOnClass(name = {"org.eclipse.jetty.server.handler.ContextHandler"})
3941
@Configuration(proxyBeanMethods = false)
4042
public class JettyServerCustomizerConfig {
4143

4244
@Bean
4345
public JettyServerCustomizer jettyServerCustomizer() {
4446
return (server) -> {
47+
ContextHandler handler = (ContextHandler) server.getHandler();
48+
handler.addAliasCheck((path, resource) -> true);
49+
4550
for (Connector connector : server.getConnectors()) {
4651
connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration()
4752
.setUriCompliance(UriCompliance.LEGACY);

0 commit comments

Comments
 (0)