@vibe-lark/larkpal 0.1.79 → 0.1.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.mjs +9 -0
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -4583,6 +4583,8 @@ async function handleSessionFileUpload(req, res, messageStore) {
|
|
|
4583
4583
|
traceId,
|
|
4584
4584
|
runtimeEventType: "session-file-attached",
|
|
4585
4585
|
fileName: file.fileName,
|
|
4586
|
+
originalName: file.originalName,
|
|
4587
|
+
displayName: file.displayName,
|
|
4586
4588
|
relativePath: file.relativePath,
|
|
4587
4589
|
mimeType: file.mimeType,
|
|
4588
4590
|
size: file.size,
|
|
@@ -4613,6 +4615,7 @@ function parseSessionFileUpload(req, sessionId) {
|
|
|
4613
4615
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
4614
4616
|
const busboy = Busboy({
|
|
4615
4617
|
headers: req.headers,
|
|
4618
|
+
defParamCharset: "utf8",
|
|
4616
4619
|
limits: {
|
|
4617
4620
|
fileSize: getSessionFileUploadMaxBytes(),
|
|
4618
4621
|
files: 1
|
|
@@ -4676,6 +4679,7 @@ function writeSessionFile(sessionId, params) {
|
|
|
4676
4679
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
4677
4680
|
const uploadsDir = resolve(resolveAgentCwd(sessionId), "uploads");
|
|
4678
4681
|
const fileName = buildSafeUploadFileName(params.originalName);
|
|
4682
|
+
const originalName = buildDisplayUploadFileName(params.originalName);
|
|
4679
4683
|
const destination = resolve(uploadsDir, fileName);
|
|
4680
4684
|
const relativePath = `uploads/${fileName}`;
|
|
4681
4685
|
const maxBytes = getSessionFileUploadMaxBytes();
|
|
@@ -4713,6 +4717,8 @@ function writeSessionFile(sessionId, params) {
|
|
|
4713
4717
|
sessionId,
|
|
4714
4718
|
kind: "session-file",
|
|
4715
4719
|
fileName,
|
|
4720
|
+
originalName,
|
|
4721
|
+
displayName: originalName,
|
|
4716
4722
|
relativePath,
|
|
4717
4723
|
uri: `session-file://${relativePath}`,
|
|
4718
4724
|
mimeType: params.mimeType,
|
|
@@ -4737,6 +4743,9 @@ function buildSafeUploadFileName(originalName) {
|
|
|
4737
4743
|
const stem = basename(base, extname(base)).replace(/[^A-Za-z0-9._-]/g, "_").replace(/^\.+$/, "").slice(0, 80) || "upload";
|
|
4738
4744
|
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}-${stem}${extension}`;
|
|
4739
4745
|
}
|
|
4746
|
+
function buildDisplayUploadFileName(originalName) {
|
|
4747
|
+
return basename(originalName).replace(/[\0\r\n]/g, "_").trim() || "upload.bin";
|
|
4748
|
+
}
|
|
4740
4749
|
function isPathInside(parent, child) {
|
|
4741
4750
|
const path = relative(parent, child);
|
|
4742
4751
|
return path !== "" && !path.startsWith("..") && !isAbsolute(path);
|