解决TOMCAT高版本兼容问题

This commit is contained in:
keyuan 2021-04-24 16:41:22 +08:00
parent c4ec7ccef5
commit 0e868bf85f
2 changed files with 12 additions and 5 deletions

View File

@ -47,6 +47,13 @@ public class XssHttpWrapper extends HttpServletRequestWrapper {
*/
@Override
public String getHeader(String name) {
if("If-None-Match".equals(name)){
// W/"14873-1619252839000"
String value = super.getHeader(name);
if(value==null || value.length()<50){
return super.getHeader(name);
}
}
String value = super.getHeader(xssEncode(name));
if (value != null) {
value = xssEncode(value);
@ -54,8 +61,8 @@ public class XssHttpWrapper extends HttpServletRequestWrapper {
return value;
}
/**
*
* @param name
@ -169,6 +176,7 @@ public class XssHttpWrapper extends HttpServletRequestWrapper {
*/
public String xssEncode(String s)
{
if (s == null || s.isEmpty())
{
return s;
@ -188,7 +196,6 @@ public class XssHttpWrapper extends HttpServletRequestWrapper {
result = escape(result);
}
}
return result;
}
@ -247,4 +254,4 @@ public class XssHttpWrapper extends HttpServletRequestWrapper {
}
return value;
}
}
}

View File

@ -47,7 +47,7 @@
</filter-mapping>
<!-- 配置Java Xss保护过滤器 -->
<filter>
<filter>
<filter-name>xssFilter</filter-name>
<filter-class>com.key.common.plugs.xss.XssFilter</filter-class>
</filter>