Skip to content

Commit c6f0158

Browse files
committed
fix(media): treat legacy .doc containers as binary
1 parent 2a40612 commit c6f0158

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/media-understanding/apply.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,4 +1203,22 @@ describe("applyMediaUnderstanding", () => {
12031203
expect(ctx.Body).toContain("<file");
12041204
expect(ctx.Body).toContain("vendor-json");
12051205
});
1206+
1207+
it("skips legacy Office binary formats carried as msword or x-cfb", async () => {
1208+
const oleMagic = Buffer.from("d0cf11e0a1b11ae1", "hex");
1209+
for (const mime of ["application/msword", "application/x-cfb"]) {
1210+
const filePath = await createTempMediaFile({
1211+
fileName: mime === "application/msword" ? "legacy.doc" : "legacy.cfb",
1212+
content: oleMagic,
1213+
});
1214+
1215+
const { ctx, result } = await applyWithDisabledMedia({
1216+
body: "<media:file>",
1217+
mediaPath: filePath,
1218+
mediaType: mime,
1219+
});
1220+
1221+
expectFileNotApplied({ ctx, result, body: "<media:file>" });
1222+
}
1223+
});
12061224
});

src/media-understanding/apply.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ function isBinaryMediaMime(mime?: string): boolean {
299299
mime === "application/gzip" ||
300300
mime === "application/x-gzip" ||
301301
mime === "application/x-rar-compressed" ||
302-
mime === "application/x-7z-compressed"
302+
mime === "application/x-7z-compressed" ||
303+
mime === "application/x-cfb" ||
304+
mime === "application/msword"
303305
) {
304306
return true;
305307
}

0 commit comments

Comments
 (0)