Files
craft-libs/crates/doc-binary
kiwi4boy 387eab39f4 .doc import: Word 6.0/95 files open with their text, formatting, tables and styles
Ported from storytold/wordcraft#6317, #6335 and #6345 (one series): Word 6.0
and Word 95 files are read instead of refused: text in its code page (by font
charset, language and style), character and paragraph formatting, tables and
paragraph styles. Paths follow craft-doc-binary (craft-wordmodel,
craft-codepage, craft-cfb).

(cherry picked from commit aa220afc77)
2026-11-14 13:27:16 -05:00
..

craft-doc-binary

Reader for the Word 97-2003 binary file format (.doc, [MS-DOC]) into the craft-wordmodel document model. It is WordCraft's reader, on craft-cfb for the compound file and craft-codepage for 8-bit text.

// Not a compound file: an error, never a panic.
assert!(craft_doc_binary::read(b"not a .doc").is_err());
assert!(!craft_doc_binary::is_encrypted(b"not a .doc"));
  • read(bytes), read_with_password(bytes, Option<&str>), is_encrypted(bytes).
  • Text in pieces (8-bit and UTF-16), paragraph and character formatting, styles, lists, tables, sections, headers and footers, notes, comments, fields, bookmarks, pictures and OfficeArt shapes, document properties.
  • XOR obfuscation, RC4 and RC4 CryptoAPI password protection.

There is no writer.

Limits

Streams (1 GiB each, refused by craft-cfb before anything is allocated), paragraphs, pieces, property counts, table nesting and drawing records are capped; the constants are in the source next to what they bound, and each has a test. Hostile input gives an error or a best-effort document, never a panic.