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 to support non-ASCII filenames
The X-File-Results header contained raw JSON with non-ASCII characters from filenames (Chinese, Japanese, etc.), violating RFC 7230. Node.js threw ERR_INVALID_CHAR on writeHead(). Fixed by wrapping the JSON in encodeURIComponent() on the backend and decodeURIComponent() on the frontend, ensuring only ASCII goes into the header while preserving the original filenames after decoding. Closes #133
This commit is contained in:
@@ -3102,7 +3102,7 @@ describe("Batch processing", () => {
|
||||
});
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.headers["x-file-results"]).toBeDefined();
|
||||
const parsed = JSON.parse(res.headers["x-file-results"] as string);
|
||||
const parsed = JSON.parse(decodeURIComponent(res.headers["x-file-results"] as string));
|
||||
expect(parsed["0"]).toBeDefined();
|
||||
expect(parsed["1"]).toBeDefined();
|
||||
});
|
||||
@@ -3189,7 +3189,7 @@ describe("Batch processing", () => {
|
||||
|
||||
const fileResults = res.headers["x-file-results"];
|
||||
expect(fileResults).toBeDefined();
|
||||
const parsed = JSON.parse(fileResults as string);
|
||||
const parsed = JSON.parse(decodeURIComponent(fileResults as string));
|
||||
expect(parsed["0"]).toBeDefined();
|
||||
expect(parsed["1"]).toBeDefined();
|
||||
expect(typeof parsed["0"]).toBe("string");
|
||||
@@ -3215,7 +3215,7 @@ describe("Batch processing", () => {
|
||||
});
|
||||
expect(res.statusCode).toBe(200);
|
||||
|
||||
const fileResults = JSON.parse(res.headers["x-file-results"] as string);
|
||||
const fileResults = JSON.parse(decodeURIComponent(res.headers["x-file-results"] as string));
|
||||
const names = [fileResults["0"], fileResults["1"], fileResults["2"]];
|
||||
expect(names[0]).toContain("aaa");
|
||||
expect(names[1]).toContain("bbb");
|
||||
|
||||
Reference in New Issue
Block a user