mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 优化魔法值
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.common.filter;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
@ -23,8 +24,8 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException {
|
||||
super(request);
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
request.setCharacterEncoding(Constants.UTF8);
|
||||
response.setCharacterEncoding(Constants.UTF8);
|
||||
|
||||
body = IoUtil.readUtf8(request.getInputStream()).getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.common.filter;
|
||||
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
import javax.servlet.*;
|
||||
@ -48,7 +49,7 @@ public class XssFilter implements Filter {
|
||||
String url = request.getServletPath();
|
||||
String method = request.getMethod();
|
||||
// GET DELETE 不过滤
|
||||
if (method == null || method.matches("GET") || method.matches("DELETE")) {
|
||||
if (method == null || method.matches(ServletUtil.METHOD_GET) || method.matches(ServletUtil.METHOD_DELETE)) {
|
||||
return true;
|
||||
}
|
||||
return StringUtils.matches(url, excludes);
|
||||
|
@ -89,10 +89,9 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
/**
|
||||
* 是否是Json请求
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
public boolean isJsonRequest() {
|
||||
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
|
||||
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class ServletUtils extends ServletUtil {
|
||||
public static boolean isAjaxRequest(HttpServletRequest request) {
|
||||
|
||||
String accept = request.getHeader("accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
if (accept != null && accept.contains(MediaType.APPLICATION_JSON_VALUE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user