mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: percent-encode X-File-Results header for non-ASCII filenames (#133)
Closes #133
This commit is contained in:
@@ -4470,7 +4470,7 @@ paths:
|
||||
X-File-Results:
|
||||
schema:
|
||||
type: string
|
||||
description: JSON mapping of input index to output filename
|
||||
description: Percent-encoded JSON mapping of input index to output filename (decode with decodeURIComponent before JSON.parse)
|
||||
content:
|
||||
application/zip:
|
||||
schema:
|
||||
|
||||
@@ -262,7 +262,7 @@ export async function registerBatchRoutes(app: FastifyInstance): Promise<void> {
|
||||
"Content-Disposition": `attachment; filename="batch-${toolId}-${jobId.slice(0, 8)}.zip"`,
|
||||
"Transfer-Encoding": "chunked",
|
||||
"X-Job-Id": jobId,
|
||||
"X-File-Results": JSON.stringify(fileResultsMap),
|
||||
"X-File-Results": encodeURIComponent(JSON.stringify(fileResultsMap)),
|
||||
});
|
||||
|
||||
const archive = archiver("zip", { zlib: { level: 5 } });
|
||||
|
||||
@@ -731,7 +731,7 @@ export async function registerPipelineRoutes(app: FastifyInstance): Promise<void
|
||||
"Content-Disposition": `attachment; filename="pipeline-batch-${jobId.slice(0, 8)}.zip"`,
|
||||
"Transfer-Encoding": "chunked",
|
||||
"X-Job-Id": jobId,
|
||||
"X-File-Results": JSON.stringify(fileResultsMap),
|
||||
"X-File-Results": encodeURIComponent(JSON.stringify(fileResultsMap)),
|
||||
});
|
||||
|
||||
const archive = archiver("zip", { zlib: { level: 5 } });
|
||||
|
||||
@@ -320,7 +320,7 @@ export function registerSvgToRaster(app: FastifyInstance) {
|
||||
"Content-Disposition": `attachment; filename="batch-svg-to-raster-${jobId.slice(0, 8)}.zip"`,
|
||||
"Transfer-Encoding": "chunked",
|
||||
"X-Job-Id": jobId,
|
||||
"X-File-Results": JSON.stringify(fileResultsMap),
|
||||
"X-File-Results": encodeURIComponent(JSON.stringify(fileResultsMap)),
|
||||
});
|
||||
|
||||
const archive = archiver("zip", { zlib: { level: 5 } });
|
||||
|
||||
@@ -330,7 +330,9 @@ export function usePipelineProcessor() {
|
||||
const entries = useFileStore.getState().entries;
|
||||
let fileResults: Record<string, string> = {};
|
||||
try {
|
||||
fileResults = JSON.parse(response.headers.get("X-File-Results") ?? "{}");
|
||||
fileResults = JSON.parse(
|
||||
decodeURIComponent(response.headers.get("X-File-Results") ?? "%7B%7D"),
|
||||
);
|
||||
} catch {
|
||||
// Malformed header - fall back to empty mapping, all entries marked failed
|
||||
}
|
||||
|
||||
@@ -384,7 +384,9 @@ export function useToolProcessor(toolId: string) {
|
||||
const entries = useFileStore.getState().entries;
|
||||
let fileResults: Record<string, string> = {};
|
||||
try {
|
||||
fileResults = JSON.parse(response.headers.get("X-File-Results") ?? "{}");
|
||||
fileResults = JSON.parse(
|
||||
decodeURIComponent(response.headers.get("X-File-Results") ?? "%7B%7D"),
|
||||
);
|
||||
} catch {
|
||||
// Malformed header - fall back to empty mapping, all entries marked failed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user