Skip to content

Commit 918954a

Browse files
committed
fix(sandbox): prevent opts from clobbering computed ImageRun data/type/transformation
1 parent 86c6ba8 commit 918954a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

apps/sim/sandbox-tasks/docx-generate.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ export const docxGenerateTask = defineSandboxTask<SandboxTaskInput>({
6363
const ext = extMap[mime];
6464
if (!ext) throw new Error('addImage: unsupported image type "' + mime + '". Use PNG, JPEG, GIF, BMP, or SVG.');
6565
if (!globalThis.Buffer) throw new Error('addImage: Buffer polyfill missing — ensure docx bundle is loaded');
66-
return new globalThis.docx.ImageRun(Object.assign({
66+
const { width, height, type: _t, data: _d, transformation: userTransform, ...passThrough } = opts || {};
67+
return new globalThis.docx.ImageRun(Object.assign(passThrough, {
6768
data: globalThis.Buffer.from(base64, 'base64'),
68-
transformation: { width: opts?.width ?? 200, height: opts?.height ?? 200 },
6969
type: ext,
70-
}, opts || {}));
70+
transformation: Object.assign({ width: width ?? 200, height: height ?? 200 }, userTransform || {}),
71+
}));
7172
};
7273
`,
7374
// JSZip's browser build doesn't support nodebuffer output, so we go through

0 commit comments

Comments
 (0)