encode fix

This commit is contained in:
2026-01-17 10:55:43 +08:00
parent e65f5f4660
commit e5de7836e0
3 changed files with 8 additions and 8 deletions

View File

@@ -25,6 +25,6 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public ResponseEntity<?> handleException(Exception e) { public ResponseEntity<?> handleException(Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Map.of("success", false, "message", "æœ<EFBFBD>务器内部错è¯? " + e.getMessage())); .body(Map.of("success", false, "message", "服务器内部错误: " + e.getMessage()));
} }
} }

View File

@@ -62,7 +62,7 @@ public class FullApiFilter implements Filter {
String method = wrappedRequest.getMethod(); String method = wrappedRequest.getMethod();
String params; String params;
// 登录接å<EFBFBD>£ç™»å½•æˆ<EFBFBD>功(状æ€<EFBFBD>ç <EFBFBD> 2xx)时ä¸<C3A4>记录å<E280A2>数,仅记录失败日å¿? // 登录接口登录成功(状态码 2xx时不记录参数仅记录失败日志
if ("/access/login".equals(servletPath) && httpRes.getStatus() >= 200 && httpRes.getStatus() < 300) { if ("/access/login".equals(servletPath) && httpRes.getStatus() >= 200 && httpRes.getStatus() < 300) {
params = "[PROTECTED]"; params = "[PROTECTED]";
} else { } else {
@@ -84,7 +84,7 @@ public class FullApiFilter implements Filter {
opLog.setUsername(auth.getName()); opLog.setUsername(auth.getName());
} }
// 记录å<EFBFBD>¯èƒ½çš„å¼å¸¸ä¿¡æ<EFBFBD>? // 记录可能的异常信息
Object exception = req.getAttribute("filter_exception"); Object exception = req.getAttribute("filter_exception");
if (exception != null) { if (exception != null) {
opLog.setException(exception.toString()); opLog.setException(exception.toString());
@@ -143,4 +143,4 @@ public class FullApiFilter implements Filter {
return ip; return ip;
} }
} }

View File

@@ -85,14 +85,14 @@ public class BaseEncoder {
return java.net.URLEncoder.encode(target, StandardCharsets.UTF_8); return java.net.URLEncoder.encode(target, StandardCharsets.UTF_8);
} }
// é‡<EFBFBD>è½½æ¹æ³•,ä¿<EFBFBD>æŒ<EFBFBD>å<EFBFBD>å<EFBFBD>Žå…¼å®? // 重载方法,保持向后兼容
public static String encodeByTarget(String target) { public static String encodeByTarget(String target) {
return encodeByTarget(target, Algorithm.REMOVE_SPECIAL_CHARS); return encodeByTarget(target, Algorithm.REMOVE_SPECIAL_CHARS);
} }
// å·¥å…·æ¹æ³•:验è¯<EFBFBD>ç¼ç <EFBFBD>结æž? // 工具方法:验证编码结果
public static boolean verify(String original, String encoded, Algorithm algorithm) { public static boolean verify(String original, String encoded, Algorithm algorithm) {
String newEncoded = encodeByTarget(original, algorithm); String newEncoded = encodeByTarget(original, algorithm);
return newEncoded.equals(encoded); return newEncoded.equals(encoded);
} }
} }