This commit is contained in:
2023-06-08 11:50:06 +08:00
parent 7091a8ce23
commit 06cb41fff7
5 changed files with 18 additions and 21 deletions

View File

@@ -12,6 +12,7 @@ import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -308,7 +309,7 @@ public class RedisCache {
.count(10000).build())) {
while (cursor.hasNext()) {
keysTmp.add(new String(cursor.next(), "Utf-8"));
keysTmp.add(new String(cursor.next(), StandardCharsets.UTF_8));
}
} catch (Exception e) {
logger.error(e.getMessage(), e);

View File

@@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* XSS过滤处理
@@ -49,14 +50,14 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
}
// 为空,直接返回
String json = IOUtils.toString(super.getInputStream(), "utf-8");
String json = IOUtils.toString(super.getInputStream(), StandardCharsets.UTF_8);
if (StringUtils.isEmpty(json)) {
return super.getInputStream();
}
// xss过滤
json = EscapeUtil.clean(json).trim();
byte[] jsonBytes = json.getBytes("utf-8");
byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8);
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
return new ServletInputStream() {
@Override