Commit Graph
2259 Commits
Author SHA1 Message Date
dotCooCoo 6701acfcf1 craft-testkit: bound collection and use-path allocations and fix guard edge cases
- fonts::collection counts the table directories from each face's
  numTables before reading any record, then adds the tables one face at a
  time, so oversized input returns OutputTooLarge without keeping a
  directory for every face.
- fonts::rename_family keeps the rest of each renamed full name, so a
  family name stored inside that suffix is refused with
  ConflictingNameStorage.
- The guards read `use<...>` as a capturing bound, not a declaration, and
  keep use paths of at most eight segments, so a long prefix shared by many
  names is not copied into each.
- std_instant finds the modules of a file that a #[path] attribute names
  next to that file, separately from a plain load of the same file.
- predefined_quit reports <muda::PredefinedMenuItem>::quit.
- wgsl_float_literals ends line comments and counts lines at every WGSL
  line break, and skips digits inside Unicode identifiers.
2026-11-14 15:03:39 -08:00
dotCooCoo 3baaac6869 Merge main into feat/craft-testkit-fonts 2026-11-14 13:26:37 -08:00
dotCooCoo 15cdfd8512 craft-testkit: fonts reads Mac Roman names by character and rewrites only the family name
rename_family compares a Macintosh Roman record with the family name
character by character, using the Unicode mapping of Mac Roman, so a
record whose non-ASCII letters differ from the name is left as it is
instead of failing the rename with UnsupportedEncoding.

A rename now writes only the bytes of the family name at the start of
each matching string, and records that point at the same string are
read once. A style name that shares the unchanged end of a full name
keeps its bytes, and a name table with many records on one long string
no longer allocates a copy of the string for each record.
2026-11-14 13:26:23 -08:00
Dylan M. Taylor f2cd524f74 Merge pull request #1112 from storytold/chore/lock-github-actions
ci: lock workflow actions through an actions.lock lockfile
2026-11-14 16:22:25 -05:00
Dylan M. Taylor d6cd7836d3 feat(video,image-codecs,stream-codecs): add encode_with_key, encode_avif_hdr, and decode_ccitt_raw (#1369) 2026-11-14 16:15:44 -05:00
dotCooCoo 88c20a3d84 Merge main into feat/craft-testkit-fonts 2026-11-14 13:10:05 -08:00
dotCooCoo 3c55995956 craft-testkit: fonts renames a test face's family and builds TrueType collections
Add the fonts module. rename_family(bytes, from, to) replaces a family
name of the same UTF-16 length in the family records (name IDs 1, 16
and 21) and in full names (ID 4) that are the name or start with it
followed by a space, in UTF-16BE and ASCII Macintosh Roman records, and
writes the name table checksum and head.checkSumAdjustment.
collection(faces) builds a TTC 1.0 with each face's own tables,
four-byte padding, file-relative offsets, zeroed checkSumAdjustment and
checksums of the copied tables.

Both return a FontError instead of panicking: names of different
lengths, no family record holding the name, a face shorter than its
table directory, tables or name strings out of range, shared name
storage that a rename would change, a collection given as a face, and
output past the 4 GiB that 32-bit offsets reach.

The code comes from the rename and collection helpers in VectorCraft,
DesignCraft and WordCraft font tests. Their tests need each app's font
database and bundled fonts, so they stay in the apps; tests/fonts.rs
tests the module on faces built in memory.
2026-11-14 13:10:05 -08:00
dotCooCoo 2abb1c6a80 craft-testkit: test the guards on split use groups, brace literals, escaped line breaks, deep nesting and broken links
New tests cover cases the guards already handle:

- wgsl_float_literals checks a literal that follows a hex literal and an
  operator (0x1.0p0+1e39, 0xFF+1e39, 0x1f-4e38).
- std_instant reports Instant in a use group split over several lines.
- '{' and '}' character literals do not end a native cfg item early.
- An escaped line break in a string keeps the line numbers after it.
- Use groups and cfg predicates nested 100,000 deep return without
  exhausting the stack.
- rust_sources skips a broken symbolic link to a file or a folder.
2026-11-14 13:03:11 -08:00
Dylan M. Taylor 79e97b6feb Merge pull request #1360 from storytold/sec/vendor-unsafe-note
vendor: record the hayro-syntax transmute as an audited exception
2026-11-14 15:59:35 -05:00
Dylan M. Taylor 712b0f792e Merge pull request #1361 from storytold/sec/psd-length-refusal
craft-psd: pin that a length not fitting 32 bits is refused, not truncated
2026-11-14 15:57:56 -05:00
dotCooCoo 2e13ad6071 Merge main into feat/craft-testkit-guards 2026-11-14 12:14:12 -08:00
Dylan M. Taylor 30209caad8 feat(gif,image-codecs): add indexed/interlaced GIF, jpeg_progressive_scans, and JP2 decode (#1358)
* feat(gif,image-codecs): add indexed/interlaced GIF, jpeg_progressive_scans, and JP2 decode

* chore: update Cargo.lock for craft-image-codecs jp2 dep

* fix(image-codecs,svg): deref jp2 ch and re-export resvg from craft_svg::tree::draw
2026-11-14 15:13:21 -05:00
dotCooCoo 5c53194e40 craft-testkit: a native cfg on a block statement covers the block and its method-call suffix
item_end now ends a cfg-gated statement that starts with a bare block at the block's closing brace, so code after it is checked. When a `.` or `?` follows the closing brace of a block item, the item runs on to its `;` or `,`, so a method call after a cfg-gated block or `unsafe` block stays covered by the cfg.
2026-11-14 12:12:08 -08:00
dotCooCoo 836433ccb9 craft-testkit: wgsl_float_literals docs say the limit check uses the value rounded to f64
README item 2, the wgsl_float_literals rustdoc and the boundary test comment now say the
scanner compares each literal's value rounded to f64, so a literal that exceeds the maximum
by less than f64 precision, such as 0x1.fffffe000000001p+127f, is not reported. They also say
0x1.fffffep+127f equals f32::MAX and 3.4028234663852886e38 rounds to it.
2026-11-14 12:01:40 -08:00
dotCooCoo 70ac080c8e Merge main into feat/craft-testkit-guards 2026-11-14 11:55:39 -08:00
dotCooCoo b89076646d craft-testkit: rust_sources docs name the CACHEDIR.TAG signature it checks
rust_sources skips a folder only when its CACHEDIR.TAG starts with the line
Signature: 8a477f597d28d172789f06886806bc55. The doc comment and the crate
README now say so instead of naming any CACHEDIR.TAG file.
2026-11-14 11:55:02 -08:00
Dylan M. Taylor d2b0bef7bf Merge pull request #1362 from storytold/sec/docpath-long-path
craft-docpath: prove a multi-megabyte UNC path parses iteratively
2026-11-14 14:53:24 -05:00
Dylan M. Taylor fae9569718 craft-docpath: prove a multi-megabyte UNC path parses iteratively 2026-11-14 14:53:16 -05:00
dotCooCoo e9185a499e Merge main into feat/craft-testkit-guards 2026-11-14 11:44:24 -08:00
Dylan M. Taylor 25abb43bde craft-psd: pin that a length not fitting 32 bits is refused, not truncated 2026-11-14 14:44:05 -05:00
Dylan M. Taylor abe4aca262 vendor: record the hayro-syntax transmute as an audited exception 2026-11-14 14:44:00 -05:00
Dylan M. Taylor 5a457dda6a Merge pull request #1341 from storytold/sec/pdf-no-rc4-create
craft-pdf: refuse to create RC4 encryption without an explicit legacy call
2026-11-14 14:43:13 -05:00
Dylan M. Taylor 9d9cd81013 Merge pull request #1344 from storytold/codex/pdfx1a-review-hardening
fix(prepress): address PDF/X review findings
2026-11-14 14:41:49 -05:00
Dylan M. Taylor cbf6ea8584 Merge pull request #1335 from storytold/codex/xml-dtd-review-hardening
fix(xml): address DTD validator review findings
2026-11-14 14:41:44 -05:00
dotCooCoo f876340323 Merge main into feat/craft-testkit-guards 2026-11-14 11:40:46 -08:00
dotCooCoo b9d451674e craft-testkit: std_instant skips module files a native-only mod declares
std_instant read each file on its own, so `#[cfg(not(target_arch =
"wasm32"))] mod native;` in lib.rs did not stop it from reporting
std::time::Instant in native.rs when both came from one rust_sources
call.

std_instant now first collects every `mod name;` declaration and treats
the file it names as native-only when the declaration is inside an item
whose cfg is false on wasm32-unknown-unknown, along with the files that
file declares. A file that a declaration outside such items also reaches
from a crate root is still checked. Module files are found by rustc's
rules: next to lib.rs, main.rs and mod.rs, in the stem folder of any
other file, below enclosing inline modules, and through #[path] on the
declaration or on an enclosing inline module. Declarations inside more
than 64 inline modules are not followed, so their files are checked.
2026-11-14 11:40:45 -08:00
Dylan M. Taylor 3a8797a7f4 Merge pull request #1345 from storytold/sec/dwg-fail-closed
craft-dwg: refuse to convert without a worker instead of running acadrust in-process
2026-11-14 14:22:47 -05:00
dotCooCoo 52b917fce5 craft-testkit: guards read Rust tokens, check hex and f16 floats, and bound rust_sources
predefined_quit and std_instant now run on a small Rust lexer instead of
a masked line search:

- Character and byte literals such as '"' no longer open a phantom
  string that hides the code after them.
- A Quit call split by tabs or a line break around :: is reported, a
  different name such as MyPredefinedMenuItem or quitter is not, and a
  use muda::PredefinedMenuItem as X rename is followed.
- std_instant reports std::time::Instant, <m>::Instant where a use binds
  m to std::time, and each use that imports std::time::Instant or
  std::time::*. A line that also names web_time is still reported, and
  an unrelated time::Instant is not.
- cfg attributes are read from code, not from strings or comments, and
  evaluated for wasm32-unknown-unknown (all, any, not, unix, windows,
  target_* keys). An outer attribute covers the item after it, an inner
  one the rest of its module. A predicate that depends on a feature or
  test is checked.

wgsl_float_literals skips integer literals, reports hexadecimal floats
above f32::MAX, and checks an h-suffixed float against 65504.

rust_sources does not follow symbolic links, skips folders that hold a
CACHEDIR.TAG file, no longer drops every file when the root itself is
under a folder named tests, and returns an error for a file over 8 MiB,
more than 256 MiB in all or more than 50,000 files.
rust_sources_with_limits takes other limits.

The tests use a scratch folder that is never reused and is removed when
a test panics. The crate is not published, and the root README lists
it.
2026-11-14 11:16:07 -08:00
Zach Shallbetter 87bbc1c711 craft-testkit: add source-level platform regression guards (closes #139)
Add craft-testkit with source guards for platform rules that broke before:
- predefined_quit: flags calls of muda PredefinedMenuItem::quit that bypass dirty document save prompts and window teardown on macOS.
- wgsl_float_literals: scans WGSL shaders using PhotoCraft's decimal float scanner and flags literals exceeding f32 finite range that fail on WebGPU compilers (Tint).
- std_instant: flags lines naming std::time::Instant without web_time in code running on the web, preventing wasm32 runtime panics.
- rust_sources: directory crawler discovering a crate's .rs sources while excluding test files and test directories.
2026-11-14 10:53:15 -08:00
Dylan M. Taylor c6221e42ff Merge remote-tracking branch 'storytold/main' into sec/pdf-no-rc4-create
# Conflicts:
#	crates/pdf/src/crypt/tests.rs
2026-11-14 13:47:06 -05:00
Dylan M. Taylor 75a654f4f8 craft-pdf, craft-pkcs7: compare password-derived verifiers without an early exit (#1340)
The PKCS#12 MAC and the PDF security handler's /U, R5/R6 and file-key
checks used plain equality, which stops at the first differing byte and
narrows a guess. Both crates now use a length-checked comparison that
folds every byte (the helper craft-offcrypto already used).
2026-11-14 13:45:48 -05:00
Dylan M. Taylor c86ea6802a craft-ora, craft-kra: charge every entry to one document-wide total (#1339)
An archive could hold many individually allowed members whose combined
decompression was unbounded, because both readers passed
max_total_bytes: u64::MAX to craft-zip. Each now passes MAX_TOTAL (4 GiB)
and every entry read is charged to it.

craft-fig's declared-entry cap drops from 1,000,000 to 100,000 to match the
other ZIP readers; its images were already bounded by Limits::max_image_total.
2026-11-14 13:45:31 -05:00
Dylan M. Taylor 74509ff055 Merge pull request #1351 from storytold/fix/reland-word6-doc-reader
craft-doc-binary: re-land Word 6.0/95 reader on main
2026-11-14 13:28:47 -05:00
Dylan M. Taylor 3032d970a6 craft-doc-binary: Word 6.0/95 text in an East Asian code page is refused, not lost
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)
2026-11-14 13:27:16 -05:00
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
Dylan M. Taylor 81e1dcec5a craft-dwg: refuse to convert without a worker instead of running acadrust here
The bridge fell back to decoding in the calling process whenever no worker
was configured, or the worker failed to start, which is exactly the case the
audit called out: acadrust allocates from sizes a hostile file declares, and
an allocation failure or stack overflow ends the process. Conversions are
now refused without a worker, a worker that cannot start is an error, and
allow_in_process() is the explicit opt-in for input known to be trusted.
2026-11-14 13:16:57 -05:00
Dylan M. Taylor d74e60b2d5 craft-pdf: refuse to create RC4 encryption without an explicit legacy call
The create() API exposed RC4-40 and RC4-128 behind a doc comment, so an app
could write files whose encryption protects nothing. create() now returns
Unsupported for both schemes; create_legacy() and
Document::set_encryption_legacy() are the explicit ways to write a file that
must stay readable by an old reader. Tests and the encrypt example, which
read and write every algorithm, use the legacy entry points.
2026-11-14 12:57:23 -05:00
Dylan M. Taylor b6b222afb0 fix(prepress): address PDF/X review findings 2026-11-14 17:45:53 +00:00
Dylan M. Taylor f5720d8f69 refactor(xml): share bounded tree-node validation 2026-11-14 17:36:14 +00:00
Dylan M. Taylor bac1a19d93 fix(xml): harden DTD validation bounds and parsing 2026-11-14 17:10:03 +00:00
Dylan M. Taylor 7ad4765ee5 Merge pull request #1325 from storytold/codex/docx-level-presence
docx: retain explicitly defined numbering levels
2026-11-14 11:48:48 -05:00
Dylan M. Taylor 3e399149a8 Merge pull request #1316 from storytold/sonar/s4790-format-hash-exclusions
sonar: ignore the weak hashes the encrypted formats require (SonarCloud S4790)
2026-11-14 11:47:14 -05:00
Dylan M. Taylor c9bf4a34a6 Merge pull request #1242 from alehel/claude/issue-1230-c0c8eb
craft-audio: write AAC, ALAC, MP3, AC-3 and E-AC-3 files
2026-11-14 11:46:38 -05:00
Dylan M. Taylor 874c94f2b1 Merge pull request #1311 from pakiat/fix/field-results-complex-script
craft-docx: a field's Thai result takes the complex-script formatting only where Word does
2026-11-14 11:43:58 -05:00
Dylan M. Taylor 9053f5389f Merge pull request #1225 from Bra1nZ/fix/7230-legacy-v3-driver-zero-media-side
fix(print): trust one side of a legacy V3 driver's paper metric
2026-11-14 11:43:38 -05:00
Dylan M. Taylor d542e68c5b Merge pull request #1305 from TrevorBrown-dev/fix/web-jpeg-oversized-xmp
image-codecs: the web JPEG encoder trims or leaves out an XMP packet past one segment
2026-11-14 11:40:56 -05:00
Dylan M. Taylor 1f96d6b6bb Merge pull request #1278 from naxvog/docx/cell-margins-without-table-style
craft-docx: a file with no default table style gives its tables no cell margins
2026-11-14 11:36:33 -05:00
Dylan M. Taylor 689bd18cb6 Merge pull request #147 from midasmatterhorn/fix/r4-print-shrink-zero-scale
print: shrink-to-fit refuses a sheet the written matrix cannot represent
2026-11-14 11:34:07 -05:00
Dylan M. Taylor 29fb8f8e86 Merge pull request #1216 from dotCooCoo/feat/craft-texture-planes
craft-texture: add bounded float image planes and texture sampling
2026-11-14 11:28:44 -05:00
Dylan M. Taylor 15b013b305 Merge pull request #637 from dotCooCoo/fix/linesweeper-sweep-doc-left-scan
linesweeper: the left intersection scan in docs/sweep.typ compares with alpha^(i+1)
2026-11-14 11:19:24 -05:00