!1804 fix: 修复由于tomcat升级导致的webhook斜杠转义不识别问题

Merge pull request !1804 from 华丽的谎言/master
This commit is contained in:
Ethan 2023-08-12 03:24:51 +00:00 committed by Gitee
commit 70be877e3a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 17 additions and 4 deletions

View File

@ -6,9 +6,13 @@ import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import org.apache.tomcat.util.buf.EncodedSolidusHandling;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableAsync;
@ -16,12 +20,14 @@ import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.util.UrlPathHelper;
import java.util.List;
/**
* @author Ethan Liu
* @class SpringbootApp
* @description 项目启动类
* @author Ethan Liu
* @create 2021-02-12 15:35
*/
*/
@SpringBootApplication(scanBasePackages = "dev.jianmu")
@MapperScan("dev.jianmu.infrastructure.mapper")
@EnableRetry
@ -48,9 +54,8 @@ import org.springframework.web.util.UrlPathHelper;
)
)
@ServletComponentScan
public class SpringbootApp implements WebMvcConfigurer {
public class SpringbootApp implements WebMvcConfigurer, WebServerFactoryCustomizer<TomcatServletWebServerFactory> {
public static void main(String[] args) {
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
SpringApplication.run(SpringbootApp.class, args);
}
@ -60,4 +65,12 @@ public class SpringbootApp implements WebMvcConfigurer {
urlPathHelper.setUrlDecode(false);
configurer.setUrlPathHelper(urlPathHelper);
}
// TODO: 此配置有安全隐患未来产品需要考虑
@Override
public void customize(TomcatServletWebServerFactory factory) {
TomcatConnectorCustomizer tomcatConnectorCustomizer =
connector -> connector.setEncodedSolidusHandling(EncodedSolidusHandling.DECODE.getValue());
factory.setTomcatConnectorCustomizers(List.of(tomcatConnectorCustomizer));
}
}