fix: decode URI components in object path handling

- Added decodeURIComponent to the objectName in getObjectByPathname and getObjectName functions to ensure proper handling of encoded paths.
- Updated newNamePath in renameProxy to decode the pathname before processing.
- Removed redundant comment regarding file renaming in renameProxy.
This commit is contained in:
2026-03-02 01:48:15 +08:00
parent 1ae4c979dc
commit a48cc48589
3 changed files with 699 additions and 757 deletions

View File

@@ -43,7 +43,7 @@
"@kevisual/ai": "^0.0.24",
"@kevisual/auth": "^2.0.3",
"@kevisual/js-filter": "^0.0.5",
"@kevisual/query": "^0.0.49",
"@kevisual/query": "^0.0.52",
"@types/busboy": "^1.5.4",
"@types/send": "^1.2.1",
"@types/ws": "^8.18.1",
@@ -58,13 +58,13 @@
"xml2js": "^0.6.2"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.995.0",
"@kevisual/api": "^0.0.59",
"@kevisual/cnb": "^0.0.28",
"@aws-sdk/client-s3": "^3.1000.0",
"@kevisual/api": "^0.0.60",
"@kevisual/cnb": "^0.0.33",
"@kevisual/context": "^0.0.8",
"@kevisual/local-app-manager": "0.1.32",
"@kevisual/logger": "^0.0.4",
"@kevisual/oss": "0.0.19",
"@kevisual/oss": "0.0.20",
"@kevisual/permission": "^0.0.4",
"@kevisual/router": "0.0.84",
"@kevisual/types": "^0.0.12",
@@ -73,8 +73,8 @@
"@types/bun": "^1.3.9",
"@types/crypto-js": "^4.2.2",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^25.3.0",
"@types/pg": "^8.16.0",
"@types/node": "^25.3.3",
"@types/pg": "^8.18.0",
"@types/semver": "^7.7.1",
"@types/xml2js": "^0.4.14",
"archiver": "^7.0.1",
@@ -82,11 +82,11 @@
"dayjs": "^1.11.19",
"dotenv": "^17.3.1",
"es-toolkit": "^1.44.0",
"ioredis": "^5.9.3",
"ioredis": "^5.10.0",
"jsonwebtoken": "^9.0.3",
"nanoid": "^5.1.6",
"p-queue": "^9.1.0",
"pg": "^8.18.0",
"pg": "^8.19.0",
"pm2": "^6.0.14",
"semver": "^7.7.4",
"zod": "^4.3.6"
@@ -96,7 +96,7 @@
"picomatch": "^4.0.2",
"ioredis": "^5.9.3"
},
"packageManager": "pnpm@10.30.1",
"packageManager": "pnpm@10.30.3",
"workspaces": [
"wxmsg"
]

1429
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -201,6 +201,8 @@ export const getObjectByPathname = (opts: {
prefix = `${user}/`; // root/resources
}
let objectName = opts.pathname.replace(replaceKey, prefix);
// 解码decodeURIComponent编码的路径
objectName = decodeURIComponent(objectName);
return { prefix, replaceKey, objectName, user, app };
}
export const getObjectName = async (req: IncomingMessage, opts?: { checkOwner?: boolean }) => {
@@ -217,6 +219,8 @@ export const getObjectName = async (req: IncomingMessage, opts?: { checkOwner?:
} else {
objectName = pathname.replace(`/${user}/${app}/`, `${user}/`); // root/resources
}
// 解码decodeURIComponent编码的路径
objectName = decodeURIComponent(objectName);
owner = user;
let isOwner = undefined;
let loginUser: Awaited<ReturnType<typeof getLoginUser>> = null;
@@ -287,7 +291,7 @@ export const renameProxy = async (req: IncomingMessage, res: ServerResponse, opt
}
const newUrl = new URL(newName, 'http://localhost');
const version = _u.searchParams.get('version') || '1.0.0';
const newNamePath = newUrl.pathname;
const newNamePath = decodeURIComponent(newUrl.pathname);
// 确保 newName 有正确的前缀路径
const newObject = getObjectByPathname({ pathname: newNamePath, version });
@@ -314,7 +318,6 @@ export const renameProxy = async (req: IncomingMessage, res: ServerResponse, opt
await oss.deleteObject(obj.name);
}
} else {
// 重命名文件
await oss.copyObject(objectName, newObjectName);
await oss.deleteObject(objectName);
copiedCount = 1;