🐛 修复本地存储文件删除失败的问题

问题:sanitizeInput 函数将 / 转义为 /,导致文件路径错误
修复:从 XSS 过滤中移除对 / 的转义,因为它是路径分隔符的合法字符

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-25 11:44:51 +08:00
parent 2fb2321750
commit 1943fea2e6

View File

@@ -162,19 +162,19 @@ app.use((req, res, next) => {
});
// XSS过滤中间件用于用户输入- 增强版
// 注意:不转义 / 因为它是文件路径的合法字符
function sanitizeInput(str) {
if (typeof str !== 'string') return str;
// 1. 基础HTML实体转义
// 1. 基础HTML实体转义(不包括 / 因为是路径分隔符)
let sanitized = str
.replace(/[&<>"'\/`]/g, (char) => {
.replace(/[&<>"'`]/g, (char) => {
const map = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'/': '&#x2F;',
'`': '&#x60;'
};
return map[char];