mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-14 22:42:46 +00:00
The review of wordcraft#6345 found that text in code page 932, 936, 949 or 950
was read a byte at a time, each byte above ASCII becoming U+FFFD, and the file
opened with its characters gone. Such a file is refused as every Word 6.0/95
file was before, until the piece walk decodes byte pairs. The test that
asserted the replacement characters is replaced by one that asserts the
refusal and that the same text in a Western font still opens.
The module comment on the Word 6 stylesheet header now matches the reader (a
u16 header size, then the header), as the other review comment asked.
(cherry picked from commit 92f8dd24d1)
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.