Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions api/src/job-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
inputsLiveUnder,
mapWithConcurrency,
mimeTypeFor,
isSupportedOutputFilename,
} from './job';
import type { Runtime } from './runtime';
import type { TFile } from './job';
Expand Down Expand Up @@ -84,6 +85,13 @@ describe('mimeTypeFor', () => {
expect(mimeTypeFor('logs.tar.gz')).toBe('application/gzip');
});

it('returns the registered MIME for Office macro and template formats', () => {
expect(mimeTypeFor('calc.xlsm')).toBe('application/vnd.ms-excel.sheet.macroEnabled.12');
expect(mimeTypeFor('letter.docm')).toBe('application/vnd.ms-word.document.macroEnabled.12');
expect(mimeTypeFor('deck.pptm')).toBe('application/vnd.ms-powerpoint.presentation.macroEnabled.12');
expect(mimeTypeFor('master.potx')).toBe('application/vnd.openxmlformats-officedocument.presentationml.template');
});

it('falls back to application/octet-stream for unknown extensions', () => {
expect(mimeTypeFor('mystery.qwerty')).toBe('application/octet-stream');
});
Expand Down Expand Up @@ -492,3 +500,19 @@ describe('ensureNodeModulesSymlink', () => {
}
});
});

describe('isSupportedOutputFilename', () => {
it('collects Office macro-enabled, binary and template outputs', () => {
for (const name of ['calc.xlsm', 'CALC.XLSM', 'big.xlsb', 'tpl.xltx', 'tpl.xltm', 'letter.docm',
'tpl.dotx', 'tpl.dotm', 'deck.pptm', 'master.potx', 'master.potm', 'show.ppsx', 'show.ppsm', 'draw.odg']) {
expect(isSupportedOutputFilename(name)).toBe(true);
}
});

it('still collects the existing formats and skips unknown ones', () => {
expect(isSupportedOutputFilename('report.xlsx')).toBe(true);
expect(isSupportedOutputFilename('notes.txt')).toBe(true);
expect(isSupportedOutputFilename('vbaProject.bin')).toBe(false);
expect(isSupportedOutputFilename('mystery.qwerty')).toBe(false);
});
});
18 changes: 17 additions & 1 deletion api/src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,19 @@ const MIME_TYPE_BY_EXTENSION: ReadonlyMap<string, string> = new Map([
['.odt', 'application/vnd.oasis.opendocument.text'],
['.ods', 'application/vnd.oasis.opendocument.spreadsheet'],
['.odp', 'application/vnd.oasis.opendocument.presentation'],
['.docm', 'application/vnd.ms-word.document.macroEnabled.12'],
['.dotx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'],
['.dotm', 'application/vnd.ms-word.template.macroEnabled.12'],
['.xlsm', 'application/vnd.ms-excel.sheet.macroEnabled.12'],
['.xlsb', 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'],
['.xltx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'],
['.xltm', 'application/vnd.ms-excel.template.macroEnabled.12'],
['.pptm', 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'],
['.potx', 'application/vnd.openxmlformats-officedocument.presentationml.template'],
['.potm', 'application/vnd.ms-powerpoint.template.macroEnabled.12'],
['.ppsx', 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'],
['.ppsm', 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'],
['.odg', 'application/vnd.oasis.opendocument.graphics'],
// Text / structured text
['.txt', 'text/plain'],
['.log', 'text/plain'],
Expand Down Expand Up @@ -543,6 +556,9 @@ const SUPPORTED_EXTENSIONS = new Set([
'.conf', '.env', '.gitignore', '.ini', '.properties', '.toml',
'.doc', '.docx', '.pdf', '.ppt', '.pptx', '.xls', '.xlsx',
'.odt', '.ods', '.odp', '.rtf',
/* Office macro-enabled, binary and template formats (innFactory): */
'.docm', '.dotx', '.dotm', '.xlsm', '.xlsb', '.xltx', '.xltm',
'.pptm', '.potx', '.potm', '.ppsx', '.ppsm', '.odg',
'.avif', '.bmp', '.gif', '.ico', '.jpeg', '.jpg', '.png',
'.tif', '.tiff', '.webp',
'.eot', '.ttf', '.woff', '.woff2',
Expand All @@ -554,7 +570,7 @@ const SUPPORTED_EXTENSIONS = new Set([
'.bat', '.cmd', '.deb', '.log', '.rpm', '.vbs',
]);

function isSupportedOutputFilename(name: string): boolean {
export function isSupportedOutputFilename(name: string): boolean {
const basename = path.basename(name);
const ext = path.extname(basename).toLowerCase();
const dottedBasename = `.${basename}`;
Expand Down
4 changes: 4 additions & 0 deletions packages/code/src/protocol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,10 @@ test('bridge artifact policy and media types match the hardened gateway contract
assert.equal(isSupportedBridgeArtifactName('reports/result.json'), true);
assert.equal(isSupportedBridgeArtifactName('preview.png'), true);
assert.equal(isSupportedBridgeArtifactName('model.bin'), false);
assert.equal(isSupportedBridgeArtifactName('calc.xlsm'), true);
assert.equal(isSupportedBridgeArtifactName('out/LETTER.DOCM'), true);
assert.equal(isSupportedBridgeArtifactName('master.potx'), true);
assert.equal(bridgeArtifactMediaType('calc.xlsm'), 'application/vnd.ms-excel.sheet.macroEnabled.12');
assert.equal(bridgeArtifactMediaType('preview.png'), 'image/png');
assert.equal(bridgeArtifactMediaType('reports/result.json'), 'application/json');
assert.equal(bridgeArtifactMediaType('Dockerfile'), 'application/octet-stream');
Expand Down
27 changes: 27 additions & 0 deletions packages/code/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ const BRIDGE_ARTIFACT_EXTENSIONS = new Set([
'.ods',
'.odp',
'.rtf',
/* Office macro-enabled, binary and template formats (innFactory): */
'.docm',
'.dotx',
'.dotm',
'.xlsm',
'.xlsb',
'.xltx',
'.xltm',
'.pptm',
'.potx',
'.potm',
'.ppsx',
'.ppsm',
'.odg',
'.avif',
'.bmp',
'.gif',
Expand Down Expand Up @@ -222,6 +236,19 @@ const BRIDGE_ARTIFACT_MEDIA_TYPES: Readonly<Record<string, string>> = {
'.odt': 'application/vnd.oasis.opendocument.text',
'.ods': 'application/vnd.oasis.opendocument.spreadsheet',
'.odp': 'application/vnd.oasis.opendocument.presentation',
'.docm': 'application/vnd.ms-word.document.macroEnabled.12',
'.dotx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'.dotm': 'application/vnd.ms-word.template.macroEnabled.12',
'.xlsm': 'application/vnd.ms-excel.sheet.macroEnabled.12',
'.xlsb': 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'.xltx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'.xltm': 'application/vnd.ms-excel.template.macroEnabled.12',
'.pptm': 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
'.potx': 'application/vnd.openxmlformats-officedocument.presentationml.template',
'.potm': 'application/vnd.ms-powerpoint.template.macroEnabled.12',
'.ppsx': 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'.ppsm': 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
'.odg': 'application/vnd.oasis.opendocument.graphics',
'.parquet': 'application/vnd.apache.parquet',
'.pdf': 'application/pdf',
'.png': 'image/png',
Expand Down
Loading