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:
20
package.json
20
package.json
@@ -43,7 +43,7 @@
|
|||||||
"@kevisual/ai": "^0.0.24",
|
"@kevisual/ai": "^0.0.24",
|
||||||
"@kevisual/auth": "^2.0.3",
|
"@kevisual/auth": "^2.0.3",
|
||||||
"@kevisual/js-filter": "^0.0.5",
|
"@kevisual/js-filter": "^0.0.5",
|
||||||
"@kevisual/query": "^0.0.49",
|
"@kevisual/query": "^0.0.52",
|
||||||
"@types/busboy": "^1.5.4",
|
"@types/busboy": "^1.5.4",
|
||||||
"@types/send": "^1.2.1",
|
"@types/send": "^1.2.1",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
@@ -58,13 +58,13 @@
|
|||||||
"xml2js": "^0.6.2"
|
"xml2js": "^0.6.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.995.0",
|
"@aws-sdk/client-s3": "^3.1000.0",
|
||||||
"@kevisual/api": "^0.0.59",
|
"@kevisual/api": "^0.0.60",
|
||||||
"@kevisual/cnb": "^0.0.28",
|
"@kevisual/cnb": "^0.0.33",
|
||||||
"@kevisual/context": "^0.0.8",
|
"@kevisual/context": "^0.0.8",
|
||||||
"@kevisual/local-app-manager": "0.1.32",
|
"@kevisual/local-app-manager": "0.1.32",
|
||||||
"@kevisual/logger": "^0.0.4",
|
"@kevisual/logger": "^0.0.4",
|
||||||
"@kevisual/oss": "0.0.19",
|
"@kevisual/oss": "0.0.20",
|
||||||
"@kevisual/permission": "^0.0.4",
|
"@kevisual/permission": "^0.0.4",
|
||||||
"@kevisual/router": "0.0.84",
|
"@kevisual/router": "0.0.84",
|
||||||
"@kevisual/types": "^0.0.12",
|
"@kevisual/types": "^0.0.12",
|
||||||
@@ -73,8 +73,8 @@
|
|||||||
"@types/bun": "^1.3.9",
|
"@types/bun": "^1.3.9",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@types/jsonwebtoken": "^9.0.10",
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
"@types/node": "^25.3.0",
|
"@types/node": "^25.3.3",
|
||||||
"@types/pg": "^8.16.0",
|
"@types/pg": "^8.18.0",
|
||||||
"@types/semver": "^7.7.1",
|
"@types/semver": "^7.7.1",
|
||||||
"@types/xml2js": "^0.4.14",
|
"@types/xml2js": "^0.4.14",
|
||||||
"archiver": "^7.0.1",
|
"archiver": "^7.0.1",
|
||||||
@@ -82,11 +82,11 @@
|
|||||||
"dayjs": "^1.11.19",
|
"dayjs": "^1.11.19",
|
||||||
"dotenv": "^17.3.1",
|
"dotenv": "^17.3.1",
|
||||||
"es-toolkit": "^1.44.0",
|
"es-toolkit": "^1.44.0",
|
||||||
"ioredis": "^5.9.3",
|
"ioredis": "^5.10.0",
|
||||||
"jsonwebtoken": "^9.0.3",
|
"jsonwebtoken": "^9.0.3",
|
||||||
"nanoid": "^5.1.6",
|
"nanoid": "^5.1.6",
|
||||||
"p-queue": "^9.1.0",
|
"p-queue": "^9.1.0",
|
||||||
"pg": "^8.18.0",
|
"pg": "^8.19.0",
|
||||||
"pm2": "^6.0.14",
|
"pm2": "^6.0.14",
|
||||||
"semver": "^7.7.4",
|
"semver": "^7.7.4",
|
||||||
"zod": "^4.3.6"
|
"zod": "^4.3.6"
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
"picomatch": "^4.0.2",
|
"picomatch": "^4.0.2",
|
||||||
"ioredis": "^5.9.3"
|
"ioredis": "^5.9.3"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.30.1",
|
"packageManager": "pnpm@10.30.3",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"wxmsg"
|
"wxmsg"
|
||||||
]
|
]
|
||||||
|
|||||||
1429
pnpm-lock.yaml
generated
1429
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -201,6 +201,8 @@ export const getObjectByPathname = (opts: {
|
|||||||
prefix = `${user}/`; // root/resources
|
prefix = `${user}/`; // root/resources
|
||||||
}
|
}
|
||||||
let objectName = opts.pathname.replace(replaceKey, prefix);
|
let objectName = opts.pathname.replace(replaceKey, prefix);
|
||||||
|
// 解码decodeURIComponent编码的路径
|
||||||
|
objectName = decodeURIComponent(objectName);
|
||||||
return { prefix, replaceKey, objectName, user, app };
|
return { prefix, replaceKey, objectName, user, app };
|
||||||
}
|
}
|
||||||
export const getObjectName = async (req: IncomingMessage, opts?: { checkOwner?: boolean }) => {
|
export const getObjectName = async (req: IncomingMessage, opts?: { checkOwner?: boolean }) => {
|
||||||
@@ -217,6 +219,8 @@ export const getObjectName = async (req: IncomingMessage, opts?: { checkOwner?:
|
|||||||
} else {
|
} else {
|
||||||
objectName = pathname.replace(`/${user}/${app}/`, `${user}/`); // root/resources
|
objectName = pathname.replace(`/${user}/${app}/`, `${user}/`); // root/resources
|
||||||
}
|
}
|
||||||
|
// 解码decodeURIComponent编码的路径
|
||||||
|
objectName = decodeURIComponent(objectName);
|
||||||
owner = user;
|
owner = user;
|
||||||
let isOwner = undefined;
|
let isOwner = undefined;
|
||||||
let loginUser: Awaited<ReturnType<typeof getLoginUser>> = null;
|
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 newUrl = new URL(newName, 'http://localhost');
|
||||||
const version = _u.searchParams.get('version') || '1.0.0';
|
const version = _u.searchParams.get('version') || '1.0.0';
|
||||||
const newNamePath = newUrl.pathname;
|
const newNamePath = decodeURIComponent(newUrl.pathname);
|
||||||
// 确保 newName 有正确的前缀路径
|
// 确保 newName 有正确的前缀路径
|
||||||
|
|
||||||
const newObject = getObjectByPathname({ pathname: newNamePath, version });
|
const newObject = getObjectByPathname({ pathname: newNamePath, version });
|
||||||
@@ -314,7 +318,6 @@ export const renameProxy = async (req: IncomingMessage, res: ServerResponse, opt
|
|||||||
await oss.deleteObject(obj.name);
|
await oss.deleteObject(obj.name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 重命名文件
|
|
||||||
await oss.copyObject(objectName, newObjectName);
|
await oss.copyObject(objectName, newObjectName);
|
||||||
await oss.deleteObject(objectName);
|
await oss.deleteObject(objectName);
|
||||||
copiedCount = 1;
|
copiedCount = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user