#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
docs(policies): trim the uploadableFile comments (#7891)
EthanHealy01912834ab8a68
diff --git a/frontend/editor/src/core/utils/uploadableFile.test.ts b/frontend/editor/src/core/utils/uploadableFile.test.tsindex bfa23b1e77..0604887011 100644--- a/frontend/editor/src/core/utils/uploadableFile.test.ts+++ b/frontend/editor/src/core/utils/uploadableFile.test.ts@@ -1,7 +1,7 @@import { describe, expect, it } from "vitest";import { uploadableFile } from "@app/utils/uploadableFile";-/** jsdom's Blob has no text(); FileReader is the one byte read it implements. */+/** jsdom's Blob has no text(). */const textOf = (file: File) =>new Promise<string>((resolve, reject) => {const reader = new FileReader();diff --git a/frontend/editor/src/core/utils/uploadableFile.ts b/frontend/editor/src/core/utils/uploadableFile.tsindex 4778ae13a1..e81e0e3ffa 100644--- a/frontend/editor/src/core/utils/uploadableFile.ts+++ b/frontend/editor/src/core/utils/uploadableFile.ts@@ -2,20 +2,12 @@* The File to put in a multipart body when the caller's File may have come back* from IndexedDB.*- * WebKit stamps a File restored from IndexedDB with a disk path into its own- * storage folder, and its form serialiser reads any File with a path from disk.- * Since Safari 26.5 the process doing the upload may not read that folder, so- * the request goes out with Content-Length 0 and no error, while the same File- * reads its bytes fine in JavaScript (https://bugs.webkit.org/show_bug.cgi?id=319985).- * The server sees a multipart request with no boundary and rejects it before- * any controller runs.- *+ * WebKit serialises such a File by reading the disk path it stamped on it, which+ * since Safari 26.5 the uploading process may not read: the request goes out with+ * Content-Length 0 and no error (https://bugs.webkit.org/show_bug.cgi?id=319985).* A File built over another File has no path, so every engine serialises it- * through the blob route, which is also the route WebKit takes for a File it- * never gave a path. That makes this wrapper correct on every browser today and- * after the upstream fix lands, whichever shape that fix takes. It references- * the bytes rather than copying them, so it is safe for arbitrarily large files,- * and it stays uploadable after the record it came from is rewritten or deleted.+ * through the blob route instead. It references the bytes rather than copying+ * them, so it is safe for arbitrarily large files.*/export function uploadableFile(file: File): File {return new File([file], file.name, {diff --git a/frontend/editor/src/proprietary/services/policyApi.test.ts b/frontend/editor/src/proprietary/services/policyApi.test.tsindex 012ebfe101..de3d7bb2e5 100644--- a/frontend/editor/src/proprietary/services/policyApi.test.ts+++ b/frontend/editor/src/proprietary/services/policyApi.test.ts@@ -18,7 +18,7 @@ function sentForm(): FormData {return post.mock.calls.at(-1)?.[1] as FormData;}-/** jsdom's Blob has no text(); FileReader is the one byte read it implements. */+/** jsdom's Blob has no text(). */const textOf = (file: File) =>new Promise<string>((resolve, reject) => {const reader = new FileReader();@@ -56,7 +56,6 @@ describe("runStoredPolicy", () => {});it("uploads a fresh File over the caller's bytes, never the caller's File object", async () => {- // A File restored from IndexedDB serialises as an empty body in WebKit; a wrapper does not.const source = document();await runStoredPolicy("policy-1", [source], "editor-file-1");diff --git a/frontend/editor/src/proprietary/services/policyApi.ts b/frontend/editor/src/proprietary/services/policyApi.tsindex 3b69bbe64e..d70a6ec9cf 100644--- a/frontend/editor/src/proprietary/services/policyApi.ts+++ b/frontend/editor/src/proprietary/services/policyApi.ts@@ -38,7 +38,6 @@ export async function runStoredPolicy(fileId?: string,): Promise<string> {const form = new FormData();- // Wrapped: WebKit uploads a File restored from IndexedDB as an empty body.for (const file of files) form.append("fileInput", uploadableFile(file));if (fileId) form.append("fileId", fileId);// Don't set Content-Type: the HTTP client must generate multipart/form-data