|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2024 the original author or authors. |
| 2 | + * Copyright 2012-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
20 | 20 | import org.eclipse.jetty.server.AllowedResourceAliasChecker;
|
21 | 21 | import org.eclipse.jetty.server.Connector;
|
22 | 22 | import org.eclipse.jetty.server.HttpConnectionFactory;
|
| 23 | +import org.eclipse.jetty.server.handler.ContextHandler; |
23 | 24 |
|
24 | 25 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
25 | 26 | import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
|
|
29 | 30 | /**
|
30 | 31 | * {@link JettyServerCustomizer} that:
|
31 | 32 | * <ul>
|
| 33 | + * <li>Approves all aliases to allow access to unusually named static resources |
32 | 34 | * <li>Relaxes URI compliance to allow access to static resources with {@code %} in their file name.
|
33 | 35 | * </ul>
|
34 | 36 | *
|
35 | 37 | * @author Madhura Bhave
|
36 | 38 | * @author Andy Wilkinson
|
37 | 39 | */
|
38 |
| -@ConditionalOnClass(name = "org.eclipse.jetty.server.Connector") |
| 40 | +@ConditionalOnClass(name = {"org.eclipse.jetty.server.handler.ContextHandler"}) |
39 | 41 | @Configuration(proxyBeanMethods = false)
|
40 | 42 | public class JettyServerCustomizerConfig {
|
41 | 43 |
|
42 | 44 | @Bean
|
43 | 45 | public JettyServerCustomizer jettyServerCustomizer() {
|
44 | 46 | return (server) -> {
|
| 47 | + ContextHandler handler = (ContextHandler) server.getHandler(); |
| 48 | + handler.addAliasCheck((path, resource) -> true); |
| 49 | + |
45 | 50 | for (Connector connector : server.getConnectors()) {
|
46 | 51 | connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration()
|
47 | 52 | .setUriCompliance(UriCompliance.LEGACY);
|
|
0 commit comments