refactor(web): 优化部分方法使用

This commit is contained in:
2024-05-13 22:07:18 +08:00
parent f138e5cd45
commit 57eef274a3

View File

@@ -18,6 +18,7 @@ package top.continew.starter.web.autoconfigure.xss;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.*; import cn.hutool.core.util.*;
import cn.hutool.http.HtmlUtil; import cn.hutool.http.HtmlUtil;
import cn.hutool.http.Method; import cn.hutool.http.Method;
@@ -49,10 +50,10 @@ public class XssServletRequestWrapper extends HttpServletRequestWrapper {
public XssServletRequestWrapper(HttpServletRequest request, XssProperties xssProperties) throws IOException { public XssServletRequestWrapper(HttpServletRequest request, XssProperties xssProperties) throws IOException {
super(request); super(request);
this.xssProperties = xssProperties; this.xssProperties = xssProperties;
if (StrUtil.containsAny(request.getMethod().toUpperCase(), Method.POST.name(), Method.PATCH.name(), Method.PUT if (CharSequenceUtil.equalsAnyIgnoreCase(request.getMethod().toUpperCase(), Method.POST.name(), Method.PATCH
.name())) { .name(), Method.PUT.name())) {
body = IoUtil.getReader(request.getReader()).readLine(); body = IoUtil.getReader(request.getReader()).readLine();
if (StrUtil.isEmpty(body)) { if (CharSequenceUtil.isBlank(body)) {
return; return;
} }
body = this.handleTag(body); body = this.handleTag(body);
@@ -100,7 +101,7 @@ public class XssServletRequestWrapper extends HttpServletRequestWrapper {
* @return 返回处理过后内容 * @return 返回处理过后内容
*/ */
private String handleTag(String content) { private String handleTag(String content) {
if (StrUtil.isEmpty(content)) { if (CharSequenceUtil.isBlank(content)) {
return content; return content;
} }
XssMode mode = xssProperties.getMode(); XssMode mode = xssProperties.getMode();