From 4e2d7e69248b551098170d1c8838862785a8542c Mon Sep 17 00:00:00 2001 From: ddcat666 <26564566+ddcat666@users.noreply.github.com> Date: Wed, 14 Oct 2026 12:15:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20=E6=A0=BC=E5=BC=8F=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=20-=20=E4=BF=AE=E5=A4=8D=E7=B4=A0=E6=9D=90=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E4=B8=8E=E5=9B=BE=E7=89=87=E6=A0=85=E6=A0=BC=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/asset-library-picker-modal.tsx | 9 ++++- web/test/image-raster.node.test.ts | 33 +++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/web/src/components/assets/asset-library-picker-modal.tsx b/web/src/components/assets/asset-library-picker-modal.tsx index a244aa11f..0c77183ad 100644 --- a/web/src/components/assets/asset-library-picker-modal.tsx +++ b/web/src/components/assets/asset-library-picker-modal.tsx @@ -169,7 +169,14 @@ export function AssetLibraryPickerModal({ () => (remoteQuery.data?.assets || []) .filter((asset) => asset.kind !== "model" && (asset.kind !== "entity" || allowCharacters)) - .map((asset) => remoteAssetToPickerItem(asset, items.find((item) => item.id === asset.id), acceptRemoteItems, remoteItemDisabledReason?.(asset))), + .map((asset) => + remoteAssetToPickerItem( + asset, + items.find((item) => item.id === asset.id), + acceptRemoteItems, + remoteItemDisabledReason?.(asset), + ), + ), [acceptRemoteItems, allowCharacters, remoteItemDisabledReason, remoteQuery.data, items], ); const uploadInputRef = useRef(null); diff --git a/web/test/image-raster.node.test.ts b/web/test/image-raster.node.test.ts index 2cbde1558..36c3062c1 100644 --- a/web/test/image-raster.node.test.ts +++ b/web/test/image-raster.node.test.ts @@ -23,7 +23,10 @@ test("same-origin resource redirects request CORS before assigning src", async ( for (const src of ["/api/resources/image/file", "https://cdn.example/image.png", "data:image/png;base64,test", "blob:local-image"]) { await loadRasterImage(src); } - assert.deepEqual(requests.map((request) => request.crossOrigin), ["anonymous", "anonymous", "", ""]); + assert.deepEqual( + requests.map((request) => request.crossOrigin), + ["anonymous", "anonymous", "", ""], + ); } finally { globalThis.Image = originalImage; if (originalLocation) Object.defineProperty(globalThis, "location", originalLocation); @@ -57,7 +60,13 @@ test("crop, resize and split export a redirected resource without taint", async return { width: 0, height: 0, - getContext() { return { drawImage(image: { tainted: boolean }) { tainted = image.tainted; } }; }, + getContext() { + return { + drawImage(image: { tainted: boolean }) { + tainted = image.tainted; + }, + }; + }, toDataURL() { if (tainted) throw new DOMException("Tainted canvases may not be exported", "SecurityError"); outputs.push({ width: this.width, height: this.height }); @@ -82,7 +91,9 @@ test("crop, resize and split export a redirected resource without taint", async test("readable local sources skip remote resource reads", async () => { for (const url of ["data:image/png;base64,local", "blob:local-image"]) { - const source = await prepareRasterSource(url, async () => { throw new Error("must not read remote bytes"); }); + const source = await prepareRasterSource(url, async () => { + throw new Error("must not read remote bytes"); + }); assert.equal(source.url, url); source.release(); } @@ -102,8 +113,16 @@ test("resource read failures propagate without falling back to the display URL", let fetched = false; const failure = new Error("resource authorization failed"); try { - globalThis.fetch = async () => { fetched = true; throw new Error("unsafe fallback"); }; - await assert.rejects(prepareRasterSource("/api/resources/image/file", async () => { throw failure; }), (error) => error === failure); + globalThis.fetch = async () => { + fetched = true; + throw new Error("unsafe fallback"); + }; + await assert.rejects( + prepareRasterSource("/api/resources/image/file", async () => { + throw failure; + }), + (error) => error === failure, + ); assert.equal(fetched, false); } finally { globalThis.fetch = originalFetch; @@ -133,7 +152,9 @@ test("HTTP and CORS failures stop processing instead of returning an unsafe URL" globalThis.fetch = async () => new Response("forbidden", { status: 403 }); await assert.rejects(prepareRasterSource("https://cdn.example/image.png"), /原图读取失败(403)/); const failure = new TypeError("Failed to fetch"); - globalThis.fetch = async () => { throw failure; }; + globalThis.fetch = async () => { + throw failure; + }; await assert.rejects(prepareRasterSource("https://cdn.example/image.png"), (error) => error === failure); await assert.rejects(prepareRasterSource(" "), /图片地址为空/); } finally {