Release Office Tools 0.2.0
Verify / verify (push) Canceled after 0s

This commit is contained in:
2026-09-02 07:32:31 +02:00
parent a5524e27e3
commit 08b8f84f7b
50 changed files with 2196 additions and 165 deletions
+22
View File
@@ -7,11 +7,15 @@ import {
familyForFormat,
formatBytes,
formatLabel,
validateOfficePackagePrefix,
} from "../../src/office/formats";
describe("office format handling", () => {
it.each([
["REPORT.DOCX", "docx"],
["REPORT.DOCM", "docx"],
["template.xltx", "xlsx"],
["show.ppsm", "pptx"],
["notes.odt", "odt"],
["budget.xlsx", "xlsx"],
["budget.ODS", "ods"],
@@ -21,6 +25,24 @@ describe("office format handling", () => {
expect(detectOfficeFormat({ name, size: 42 })).toBe(expected);
});
it("rejects renamed compound-binary, RTF and non-package signatures", () => {
expect(() =>
validateOfficePackagePrefix(
Uint8Array.from([0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1]),
"docx",
),
).toThrow(/OLE Compound File/u);
expect(() =>
validateOfficePackagePrefix(new TextEncoder().encode("{\\rtf1"), "docx"),
).toThrow(/Rich Text Format/u);
expect(() =>
validateOfficePackagePrefix(new TextEncoder().encode("not zip!"), "xlsx"),
).toThrow(/ZIP-based/u);
expect(() =>
validateOfficePackagePrefix(Uint8Array.from([0x50, 0x4b, 3, 4]), "pptx"),
).not.toThrow();
});
it("rejects empty, oversized, unsupported and legacy inputs explicitly", () => {
const cases = [
[{ name: "empty.docx", size: 0 }, "empty-file"],