Skip to content

Commit

Permalink
fixed url support Special char (#2516)
Browse files Browse the repository at this point in the history
* fixed the special char

* fixed specal
  • Loading branch information
tigershi authored Jul 27, 2023
1 parent 635863c commit 4e29079
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
public class BootApplication{

public static void main(String[] args) throws Exception {
System.setProperty(
"org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH",
"true");
if (args.length > 0) {
for (String arg : args) {

Expand All @@ -34,8 +31,6 @@ public static void main(String[] args) throws Exception {
System.setProperty("translation.bundle.file.clean", "false");

}
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
System.setProperty("org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH", "true");
SpringApplication.run(BootApplication.class, args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol;
import org.apache.tomcat.util.buf.EncodedSolidusHandling;
import org.apache.tomcat.util.net.SSLHostConfig;
import org.apache.tomcat.util.net.SSLHostConfigCertificate;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -37,6 +38,11 @@ public ServletWebServerFactory servletContainer(ServerProperties serverPropertie
serverProperties.getServerScheme().equalsIgnoreCase(ConstantsTomcat.HTTPS_HTTP)) {
tomcat.addAdditionalTomcatConnectors(initiateHttpsConnector(serverProperties));
}
for( Connector connector :tomcat.getAdditionalTomcatConnectors()){
connector.setAllowBackslash(true);
connector.setEncodedSolidusHandling(EncodedSolidusHandling.DECODE.getValue());

}
return tomcat;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol;
import org.apache.tomcat.util.buf.EncodedSolidusHandling;
import org.apache.tomcat.util.net.SSLHostConfig;
import org.apache.tomcat.util.net.SSLHostConfigCertificate;
import org.slf4j.Logger;
Expand Down Expand Up @@ -88,6 +89,9 @@ public void customize(Connector connector) {
protocol.setCompressionMinSize(compressionMinSize);
}

connector.setAllowBackslash(true);
connector.setEncodedSolidusHandling(EncodedSolidusHandling.DECODE.getValue());

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class BootApplication {
// System.setProperty(net.sf.ehcache.CacheManager.ENABLE_SHUTDOWN_HOOK_PROPERTY, "true");
*/
public static void main(String[] args) throws Exception {
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
System.setProperty("org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH", "true");
SpringApplication.run(BootApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
*/
package com.vmware.l10n.conf;

import org.apache.tomcat.util.buf.EncodedSolidusHandling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
Expand Down Expand Up @@ -62,9 +66,6 @@ public void addInterceptors(InterceptorRegistry registry) {
public void configurePathMatch(PathMatchConfigurer configurer) {
UrlPathHelper urlPathHelper = new UrlPathHelper();
urlPathHelper.setUrlDecode(false);
urlPathHelper.setAlwaysUseFullPath(true);
configurer.setUseSuffixPatternMatch(false);
configurer.setUseRegisteredSuffixPatternMatch(true);
configurer.setUrlPathHelper(urlPathHelper);
}

Expand All @@ -73,4 +74,10 @@ public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*");
}


@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> tomcatCustomizer() {
return factory -> factory.addConnectorCustomizers(connector -> {connector.setEncodedSolidusHandling(EncodedSolidusHandling.DECODE.getValue()); connector.setAllowBackslash(true);});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public static void main(String[] args) throws Exception {
} else {
System.setProperty("translation.bundle.file.clean", "false");
}
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
System.setProperty("org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH", "true");

SpringApplication.run(LiteBootApplication.class, args);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol;
import org.apache.tomcat.util.buf.EncodedSolidusHandling;
import org.apache.tomcat.util.net.SSLHostConfig;
import org.apache.tomcat.util.net.SSLHostConfigCertificate;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -37,6 +38,11 @@ public ServletWebServerFactory servletContainer(LiteServerProperties serverPrope
serverProperties.getServerScheme().equalsIgnoreCase(ConstantsTomcat.HTTPS_HTTP)) {
tomcat.addAdditionalTomcatConnectors(initiateHttpsConnector(serverProperties));
}
for( Connector connector :tomcat.getAdditionalTomcatConnectors()){
connector.setAllowBackslash(true);
connector.setEncodedSolidusHandling(EncodedSolidusHandling.DECODE.getValue());

}
return tomcat;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol;
import org.apache.tomcat.util.buf.EncodedSolidusHandling;
import org.apache.tomcat.util.net.SSLHostConfig;
import org.apache.tomcat.util.net.SSLHostConfigCertificate;
import org.slf4j.Logger;
Expand Down Expand Up @@ -87,6 +88,9 @@ public void customize(Connector connector) {

}

connector.setAllowBackslash(true);
connector.setEncodedSolidusHandling(EncodedSolidusHandling.DECODE.getValue());

}
}

0 comments on commit 4e29079

Please sign in to comment.