Skip to content

Commit 4d82705

Browse files
openclaw-clownfish[bot]vincentkoc
authored andcommitted
fix(media): treat legacy Word docs as binary attachments
1 parent 2d53b1d commit 4d82705

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Docs: https://docs.openclaw.ai
4040

4141
### Fixes
4242

43+
- Media: treat legacy Word/OLE attachments with `application/msword` or `application/x-cfb` MIME as binary so printable-looking `.doc` files are not embedded into prompts as text. Fixes #54176; carries forward #54380. Thanks @andyliu.
4344
- Config: accept documented `browser.tabCleanup` keys in strict root config validation, so configured tab cleanup no longer fails before runtime reads it. Fixes #74577. Thanks @lonexreb and @ezdlp.
4445
- Cron: validate disabled job schedule edits before persisting updates, so invalid cron changes no longer partially mutate stored jobs. Fixes #74459. Thanks @yfge.
4546
- Channels/status: keep Telegram, Slack, and Google Chat read-only allowlist/default-target accessors on config-only paths, so status and channel summaries do not resolve SecretRef-backed runtime credentials. Thanks @eusine.

src/media-understanding/apply.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,36 @@ describe("applyMediaUnderstanding", () => {
16171617
expectFileNotApplied({ ctx, result, body: "<media:file>" });
16181618
});
16191619

1620+
it.each([
1621+
{ fileName: "legacy.doc", mediaType: "application/msword" },
1622+
{ fileName: "compound-file.doc", mediaType: "application/x-cfb" },
1623+
])(
1624+
"skips legacy Word/OLE MIME $mediaType even when explicitly allowed and bytes look printable",
1625+
async ({ fileName, mediaType }) => {
1626+
const printableOlePayload = Buffer.from(
1627+
"Root Entry WordDocument 1Table Data Microsoft Office legacy text preview",
1628+
"utf8",
1629+
);
1630+
const filePath = await createTempMediaFile({
1631+
fileName,
1632+
content: printableOlePayload,
1633+
});
1634+
1635+
const { ctx, result } = await applyWithDisabledMedia({
1636+
body: "<media:file>",
1637+
mediaPath: filePath,
1638+
mediaType,
1639+
cfg: createMediaDisabledConfigWithAllowedMimes([
1640+
"text/plain",
1641+
"application/msword",
1642+
"application/x-cfb",
1643+
]),
1644+
});
1645+
1646+
expectFileNotApplied({ ctx, result, body: "<media:file>" });
1647+
},
1648+
);
1649+
16201650
it("keeps vendor +json attachments eligible for text extraction", async () => {
16211651
const filePath = await createTempMediaFile({
16221652
fileName: "payload.bin",

src/media-understanding/apply.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ function isBinaryMediaMime(mime?: string): boolean {
362362
mime === "application/gzip" ||
363363
mime === "application/x-gzip" ||
364364
mime === "application/x-rar-compressed" ||
365-
mime === "application/x-7z-compressed"
365+
mime === "application/x-7z-compressed" ||
366+
mime === "application/msword" ||
367+
mime === "application/x-cfb"
366368
) {
367369
return true;
368370
}

0 commit comments

Comments
 (0)