@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2012 - 2024 the original author or authors .
* Copyright 2012 - 2022 the original author or authors .
*
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -20,6 +20,7 @@ import org.eclipse.jetty.http.UriCompliance;
import org.eclipse.jetty.server.AllowedResourceAliasChecker ;
import org.eclipse.jetty.server.AllowedResourceAliasChecker ;
import org.eclipse.jetty.server.Connector ;
import org.eclipse.jetty.server.Connector ;
import org.eclipse.jetty.server.HttpConnectionFactory ;
import org.eclipse.jetty.server.HttpConnectionFactory ;
import org.eclipse.jetty.server.handler.ContextHandler ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass ;
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer ;
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer ;
@ -29,19 +30,23 @@ import org.springframework.context.annotation.Configuration;
/ * *
/ * *
* { @link JettyServerCustomizer } that :
* { @link JettyServerCustomizer } that :
* < ul >
* < ul >
* < li > Approves all aliases to allow access to unusually named static resources
* < li > Relaxes URI compliance to allow access to static resources with { @code % } in their file name .
* < li > Relaxes URI compliance to allow access to static resources with { @code % } in their file name .
* < / ul >
* < / ul >
*
*
* @author Madhura Bhave
* @author Madhura Bhave
* @author Andy Wilkinson
* @author Andy Wilkinson
* /
* /
@ConditionalOnClass ( name = "org.eclipse.jetty.server.Connecto r" )
@ConditionalOnClass ( name = { "org.eclipse.jetty.server.handler. ContextHa ndl er" } )
@Configuration ( proxyBeanMethods = false )
@Configuration ( proxyBeanMethods = false )
public class JettyServerCustomizerConfig {
public class JettyServerCustomizerConfig {
@Bean
@Bean
public JettyServerCustomizer jettyServerCustomizer ( ) {
public JettyServerCustomizer jettyServerCustomizer ( ) {
return ( server ) - > {
return ( server ) - > {
ContextHandler handler = ( ContextHandler ) server . getHandler ( ) ;
handler . addAliasCheck ( ( path , resource ) - > true ) ;
for ( Connector connector : server . getConnectors ( ) ) {
for ( Connector connector : server . getConnectors ( ) ) {
connector . getConnectionFactory ( HttpConnectionFactory . class ) . getHttpConfiguration ( )
connector . getConnectionFactory ( HttpConnectionFactory . class ) . getHttpConfiguration ( )
. setUriCompliance ( UriCompliance . LEGACY ) ;
. setUriCompliance ( UriCompliance . LEGACY ) ;