Commit Graph
3007 Commits
Author SHA1 Message Date
Simon Koch-Sultan c3c19cc917 craft-latex: a starred line break shows no star
`\\*` is a line break that also forbids a page break after it. The lexer
read `\\` as the control symbol and left the `*` as text, so `a\\*b`
showed `a`, a line break, then `*b`, `\\*[3pt]` showed `*[3pt]`, and in
a tabular the next row's first cell started with `*`.

The lexer now takes the star with `\\`, so the parser and the tabular
reader see the line break they already handle, with its optional
spacing argument.
2026-11-16 11:54:29 -05:00
FredApps a58989cae9 image-codecs: skip a SubIFDs array whose offset is cut off (#1889)
camera_raw_mode read a missing SubIFDs offset as 0, so it walked the TIFF
header as the pointer array and could classify a malformed TIFF as RAW.
Skip the entry instead, matching LightCraft's classifier.
2026-11-16 10:26:36 -05:00
FredApps d60d1b0a45 Merge pull request #1868 from tsw2k/fix/docx-frame-shape
craft-docx: a frame preset shape is a border with a hole
2026-11-16 16:24:26 +01:00
FredApps dd3015c678 wordmodel: keep the kashida length of a justified paragraph (#1875)
* wordmodel: keep the kashida length of a justified paragraph

ST_Jc lowKashida, mediumKashida and highKashida were all read as
Align::Justify, so the length was lost. ParaProps and ResolvedPara now
keep it; a direct both/justify cancels an inherited length. The DOCX
reader and writer round-trip the three values.

* docx: keep a style's kashida length when writing justify

w:jc encodes alignment and kashida together. A paragraph or style
with Align::Justify and kashida unset still inherits a length from
the style chain; writing "both" would read back as Some(Kashida::None)
and cancel it. Use the resolved length in that case.
2026-11-16 10:23:22 -05:00
FredApps e622efc125 Merge pull request #1865 from tsw2k/fix/table-narrow-column-floor
craft-flow: narrow table columns keep their width on import
2026-11-16 16:15:40 +01:00
FredApps fe512d4ffa Merge pull request #1862 from tsw2k/fix/rtf-table-grid-fallback
craft-rtf: tables keep their column grid on odd rows
2026-11-16 16:15:09 +01:00
FredApps 8ee8316213 Merge pull request #1652 from D13GOOOO/docx-locked-canvas
craft-docx: read a DrawingML locked canvas as a group of its members (wordcraft#5060)
2026-11-16 16:12:08 +01:00
FredApps 9fc471fc5c psd: add Descriptor::parse_prefix for mid-stream reads (#1887)
from_bytes still requires the slice to be fully consumed. parse_prefix
returns the descriptor and the number of bytes used, matching
VersionedDescriptor, so apps can read a descriptor that is followed by
more data (layer effects, fill and adjustment blocks).

Part of #778 and effectcraft#786.
2026-11-16 10:09:54 -05:00
FredApps 43fbfaaa3b Merge pull request #1330 from keithcsqueensu/xlsb-names
craft-xlsx: read the defined names of a binary workbook
2026-11-16 16:02:07 +01:00
Dylan M. Taylor b774e4d168 psd: add bounded PackBits recovery decoding for app cutovers (#1885)
* psd: expose bounded PackBits recovery row decoding

* Clarify recovery row budget and partial-error contract
2026-11-16 09:55:44 -05:00
FredApps bea91b1861 raw: charge each DNG chunk's own output allocation against the aggregate budget (craft-libs #778) (#1884)
A lossy JPEG smaller than its tile is now budgeted by its frame, but decoding still
fills the whole tile, so the chunk's w x h x spp output is charged as well (and refused
over MAX_SAMPLES). Regression test: a 256x256 JPEG padded with comments in a
16384x16384 tile is TooLarge instead of allocating ~1.5 GiB.
2026-11-16 09:55:38 -05:00
Dylan M. Taylor 472956a8d7 feat: add craft-control (control channel protocol) (#1879)
* feat: add craft-control (control channel protocol)

Port from solidcraft: the control channel any app may share, no UI toolkit.
- Per-launch token files (32 random bytes, user-only permissions)
- Loopback server with token-based authentication
- Client that talks to the loopback server
- Request/response types (ControlRequest, ControlResponse)
- Document watch for subscribed connections waiting on changes
- Effect type for requests still running when they finish

Desktop-only (wasm32 excluded): uses getrandom for token generation.
No external dependencies beyond serde and serde_json.

* fix: update test directory names from solidcraft-control to craft-control

* Record control crate dependencies in workspace lockfile

* re-trigger CI

* chore(lock): keep the wasm-bindgen family at the version main's runners install
2026-11-16 09:55:33 -05:00
FredApps 3919a28583 svg: a scene in local coordinates, with fill rules and element ids (#778, #789) (#1859)
* svg: a scene in local coordinates, with fill rules and element ids (#778, #789)

Document::from_tree_local keeps every node in its own user space, with its
transform relative to its parent, so an app can keep geometry editable apart
from where it is placed (EffectCraft's shape layers). Paths now carry their
fill rule, id and transform, and groups their id. from_tree is unchanged:
segments, strokes and group transforms stay absolute, path transforms are the
identity.

* craft-svg: place local text and glyph groups in their own frames (#789)

* svg: pattern paints carry their tile and content (#778, #789) (#1863)

Paint::Pattern now holds the resolved tile: id, rect, transform and the
content as scene nodes in tile space. Each pattern is converted once and
shared by every use; content past the depth limit, or a pattern that refers
back to itself, has none. In absolute scenes the tile transform maps to the
document.

* craft-svg: report scene-omitted group effects and unsupported elements (#789) (#1870)
2026-11-16 09:55:27 -05:00
094537374c Integrate shared IPC with full executable ancestry validation (#1571)
* craft-ipc: local-socket server, client and discovery for Craft apps

Adds craft-ipc, the transport for a Craft app that talks to other Craft apps on
one machine. It is native only: interprocess has no wasm32 build.

- server and client: one JSON object per line, push events, a bulk connection
  for frames, token auth on every connection, connection and time limits.
- discovery: one record per running app in a per-user runtime directory, with a
  lock file that shows whether the owner is alive.
- launch, trust, cache: find an app binary, start it only after an executable
  check, keep caches in a private per-user directory.
- activate: focus hand-off between apps.
- moniker, record, payload, asset, refresh, fetch, watch: asset names, stored
  link records, open payloads, linked-file polling and a frame cache.
- PROTOCOL.md describes the wire protocol. The record schemas and fixtures are
  in the crate.

- The crate compiles and passes clippy -D warnings on x86_64-pc-windows-gnu and
  aarch64-apple-darwin. This is a compile and lint fix only. No one ran the
  Windows or macOS code paths, so this does not claim they work there.

Part of #414.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: app.activate no longer claims a request it cannot make

ActivationBackend gains can_apply_token (default false). On Linux a
token only counts when the backend can apply it to a live window.
Stock winit cannot, so the answer is false plus a request for user
attention. Wire values are unchanged. PROTOCOL.md says what each
value means.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: keep a partial reply line across client read timeouts

pull_line dropped the bytes it had read when a read timed out, so next_event
returned Ok(None) and the next read saw only the tail of the line. The client now
keeps the partial line and resumes it on the next read. A test splits an event
line across a timeout.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: scope the macOS fallback runtime directory to the user

With TMPDIR unset or relative, the fallback was the shared path /tmp/craft. The
first user to create it owned it, and every other user then failed the owner
check. The fallback is now /tmp/craft-<euid>, as on Linux. The path choice is a
pure function with a test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: fetch rejects non-finite time, bounds its queue, keeps waited-for asks

Three changes to FrameFetcher::fetch.

A non-finite time_s was queued and failed in request_reply before any socket
I/O. The worker read that as a dead connection and exited, so enough bad asks
took every worker down. fetch now returns Fetched::Failed and queues nothing.

The queue had no length limit, so stalled workers let it grow with the request
rate. It now holds at most QUEUE_MAX asks (256, a new public constant). A miss
past the cap drops the oldest queued ask and counts it in stats.skipped.

next_job dropped any job older than max_age, even when the caller had waited
longer than max_age and was still there. The caller then re-queued at the tail.
Each job now records the latest deadline of its waiting callers and is skipped
for age only when no caller is left. Tests cover each case.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: reject file:// media URLs that do not percent-decode

local_path returned None for a file:// URL with a bad percent escape, and
missing_media then skipped it, so the server accepted a local target without the
media probe. Such a URL now gets payload_invalid. URLs that name no local file
(remote host, other scheme, relative path) are still left to the app.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: open watched files without waiting on a FIFO

Tracker::poll, Tracker::new and fingerprint opened the path with File::open
before stat checked the file type. A FIFO with no writer made that open wait,
and poll_entry held the entry lock for the whole call, so one such path stalled
every link on the watcher and the watcher drop. The open now sets O_NONBLOCK
(new crate fsopen), and stat rejects the FIFO on the open handle with
LinkError::Invalid. A check before the open would not close the window between
check and open.

craft-ipc gains a unix-only dependency on libc for the open flags. libc 0.2.190
is already in Cargo.lock. The lock file gains one dependency line for craft-ipc.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: read_private checks and reads one open handle

read_private checked the path with symlink_metadata and then read it with
fs::read, so the entry could change between the two calls. On Unix it now opens
once with O_NOFOLLOW and O_NONBLOCK, checks type, owner and mode on that handle,
and reads from the same handle. A symlink is still Refused (found by looking at
the path after a failed open, because the errno differs between Unix systems), a
FIFO is Refused and cannot stall the open, and a missing file is still an I/O
error. Other platforms keep the old checks. Tests cover the symlink and FIFO
cases.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: Tracker reports an epoch it cannot raise instead of a false bump

apply saturated the epoch at u64::MAX while poll and relink still returned
bumped: true, so Change::bumped (documented as one added to the epoch) was
false and a cached frame kept passing for changed content. poll and relink now
return LinkError::Invalid and leave the tracker as it was when the bump would
pass u64::MAX. A test covers both calls.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: document write_atomic errors that follow the rename

The directory flush and the fingerprint run after the rename. An error from
either can be returned while the path already holds the new bytes. The doc
comment now says so.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: say that check_executable accepts group-writable paths

The module and function docs described the check as protection from other local
users. A group-writable file or directory passes, and the other members of its
group can replace it. The docs now state that and keep the private-group
reason. Behavior is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: refuse an auth line that completes after the deadline

authenticate returned a completed line before it looked at the deadline, so a
line that finished after auth_deadline still authenticated. The overshoot was up
to one 250 ms read poll. The deadline is now checked first, with the same
auth failure reply as the other expiry paths. A test sends the line between the
deadline and the next poll.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: do not append an error record after a partial frame write

send_frame wrote an error record whenever write_frame failed. When the failure
came from the stream (for example a send timeout in the middle of a record), the
first record was cut short, and a peer that drained the buffer then read the
error record as the rest of it. send_frame now checks that the record can be
built before it writes. A record that cannot be built gets the error record as
before. A write failure is returned alone and the bulk loop closes the
connection.

wire gains check_cfrm, the pre-write part of write_cfrm. write_cfrm behaves as
before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: LineReader applies the line limit to a last line without a newline

At end of stream LineReader::read returned a buffered line with no length
check, so a peer that sent one byte over the limit and closed its write side got
that line dispatched, while the same bytes with a newline were refused. The end
of stream path now returns TooLarge for a line over the limit. A test covers
both paths.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: answer a control reply over the line limit with payload_too_large

write_value passed every reply to write_line, which has no size check. A sink
result larger than MAX_LINE went out as one line that the client refuses, and the
rest of the line stayed unread on the connection. Replies now go through
wire::write_reply_line. A reply over the limit is replaced by a payload_too_large
error that keeps the request id. When that does not fit either, or the value has
no id, nothing is written and the request loop ends. Event lines are unchanged.

wire gains write_reply_line. write_line behaves as before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: accept a shallow or deep poll in the native ticker test

The test expected the first notice to come from a shallow poll. With a 50 ms deep
interval the poll that first sees the edit can be a deep one, so the assertion
failed on a slow or loaded machine. It now takes the deep flag from the notice
and checks every other field.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: refuse a frame stride that cannot hold one row

FrameLayout::check only tested len == stride * h, so w = 4, stride = 1, h = 3,
len = 3 was a valid rgba8 layout. A reader that splits the payload by stride
cannot decode it. frames.open, a rendered frame and the client reply parser now
require stride >= w * bytes per pixel (4 for rgba8_premul, 8 for rgba16f_premul).
open checks before it mints a ticket, so a refused layout leaves no ticket.

The bulk test source used stride 16 for rgba16f with w = 4, which needs 32. It
now uses a stride that fits the format.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: reject calendar days that do not exist in a record's created field

valid_rfc3339 checked the day only against 1 to 31, so 2026-02-31T09:30:00Z
passed LinkRecord::validate while the schema's date-time format refused it. The
year, month and day now go through chrono::NaiveDate::from_ymd_opt, as the
workspace rules require for calendar logic. The accepted syntax is unchanged.
The schema agreement table gets rows for impossible days and for leap days.

craft-ipc gains the workspace chrono dependency. chrono is already in Cargo.lock;
the lock file gains one dependency line for craft-ipc.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: make the link record moniker pattern match Moniker::parse

The asset.moniker pattern accepted any id without / ? #, so a record the schema
passed could fail LinkRecord::validate (bad or truncated escape, raw space,
escape that decodes to invalid UTF-8, id over 512 bytes). The pattern is now two
patterns under allOf. One checks the shape: unreserved characters and two-digit
escapes only, 1 to 512 of them, which is 1 to 512 decoded bytes. The other checks
that the decoded bytes are valid UTF-8, written as the well-formed UTF-8 byte
sequences. Neither uses lookahead, so any ECMA 262 engine can run them.

The schema agreement test gets rows for each case in the list above and for the
length limits, and a sweep of lead, second and tail bytes that compares the schema
verdict with the Rust verdict. This tightens the published schema: documents it
accepted that Rust refused are now refused.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: document that Assets methods must return in bounded time

Server::shutdown and drop join every connection thread, and an Assets call runs
on one with no deadline and no view of the stop flag. The trait docs now say so
and ask implementations to bound their own I/O. Behavior is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: name the writer type in the listener tests

Clippy's type_complexity lint failed on the test helper's return type. Behavior
is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: run Assets and Activate calls on detached helper threads with a deadline

Server::shutdown and drop join every connection thread, and an Assets or
Activate call ran on one with no deadline and no view of the stop flag, so a
provider that never returned made shutdown hang.

These calls now run on a helper thread (server/provider.rs). The connection
thread waits for the answer in 100 ms slices, for at most
Limits::provider_deadline (default REPLY_DEADLINE_SECS) and not past the stop
flag. On timeout the caller gets a timeout reply and the helper is detached, so
shutdown does not join it. At most 32 helper threads are alive at once, stuck
ones included, and a call past that gets a busy error without starting a thread.
A panic in a provider becomes an io_error reply.

Frames stays on the connection thread because it is one call per frame. Its
trait docs now say that the stop flag is checked before each request and that a
running call is waited for. The module docs describe the shutdown guarantee for
each provider kind.

Public API: new Limits::provider_deadline field. Tests use a provider that
blocks until released, for Assets and for Activate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: give a caller whose queued ask was dropped a Failed outcome

When the fetch queue was full, the oldest ask was dropped but its waiting
callers got no answer. They woke, found the key neither cached nor in flight,
and queued it again, which dropped another ask and repeated the cycle.

A dropped ask now records a failure for its key before the waiters are woken, so
each waiter returns Fetched::Failed and does not queue the key again. The
drop-oldest policy and stats.skipped are unchanged. Failure records are
shared with the worker path and kept to a fixed number, oldest first.

No type or variant changes. The Fetched::Failed doc now covers this case. A test
overflows the queue while a caller waits on the oldest key, and checks that the
caller returns at once and that no further asks are dropped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: require two hex digits in a file URL percent escape

percent_decode used u8::from_str_radix, which accepts a leading plus, so
file:///tmp/a%+fb decoded to the byte 0x0f and went on to the media probe
instead of getting payload_invalid. The two bytes after a percent sign must now
both be ASCII hex digits. The decode test gets a plus, a minus, a space and a
short escape.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: make the euid probe create only its own file, and gate the macOS path test

On Unix systems other than Linux, current_euid read the owner of a file named
.craft-uid-<pid> in the temp directory, made with create and truncate. A file or
symlink planted at that name was opened and truncated. The probe now lives in
probe_euid: random name, create_new (which refuses an existing path), mode 0600,
and removal before it returns. The std library has no safe euid call and this
crate forbids unsafe code, so the probe stays. A test plants a file and a symlink
at the old and a similar name and checks that both are untouched and that the
probe file is gone.

macos_fallback_is_per_user compares Unix paths, so it and the macos_runtime_path
helper it needs are now compiled for tests on Unix only. That removes the unused
function warning in Windows test builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* craft-ipc: an event larger than one line becomes an events.overflow marker

Server::emit wrote the serialized event unchecked. A line over MAX_LINE made
Client::next_event return TooLarge and left the stream out of sync. enqueue
now checks the serialized size and queues the existing overflow marker instead.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFCDiYoKS325v2rtv2F7D8

* ipc: validate executable path ancestry

* ipc: preserve queued replies after macOS peer shutdown

* ipc: validate native transports and use portable platform fixtures

* Make IPC integration fixtures portable and collision-free

* Use native paths and unique directories across IPC fixtures

* Bound Windows pipe I/O and stabilize IPC tests

* Retry empty nonblocking Windows pipes

* #433: Serialize hub tests sharing a Windows pipe

* #433: Use native endpoint in schema capability tests

* ipc: report a non-regular watch target as Invalid on every platform

* ipc: format the new error classification

---------

Co-authored-by: User <bigwolfeman@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 09:55:22 -05:00
Dylan M. TaylorandSkaywalker eeae2bb7ca feat(ssip): extract bounded Speech Dispatcher wire helpers (#1500)
Adapted from WordCraft SSIP implementation; preserves contributor framing behavior while rejecting overlong complete lines.

Co-authored-by: Skaywalker <115165402+Skaywalker@users.noreply.github.com>
2026-11-16 09:55:17 -05:00
Dylan M. Taylor 9ac3245966 settings, atomic: give a replaced file's group bits only to its group (#558)
* settings, atomic: give a replaced file's group bits only to its group

write_backup copied the config's mode onto a new backup inode without
giving it the config's group, and craft-atomic's stage() did the same
for every replaced file: on a setgid directory or with another primary
group, the group bits opened the contents to a group never granted
them. Both now chown the new inode to the replaced file's group first
and drop the group bits when that fails.

* address review: skip fchown when the stage already has the replaced file's group

* atomic: route the stage's group change through AtomicFs so the fallback is tested
2026-11-16 09:55:13 -05:00
FredApps e2df3ce493 Merge pull request #1844 from storytold/feature/craft-unzip
craft-zip: Craft Anything's hardened ZIP reader as craft_zip::lenient
2026-11-16 15:52:03 +01:00
Dylan M. Taylor dd8f6b144f Merge pull request #1880 from storytold/fix/svg-writer-declaration-validation
fix(svg): validate XML declaration and DTD subset boundaries
2026-11-16 09:41:05 -05:00
FredApps c7a872e2f2 Merge pull request #1878 from storytold/onee/778-svg-guard-path
craft-svg: bound entity scans and reset smooth controls after Z
2026-11-16 15:13:24 +01:00
FredApps e60702ab1c Merge pull request #1861 from storytold/render-parity-harness
craft-render-parity: compare two renders against a stated tolerance (#587)
2026-11-16 15:02:00 +01:00
FredApps e836b6fd89 Merge pull request #1849 from storytold/feature/craft-macho
Add craft-macho: Mach-O slice tables and header names from Craft Anything
2026-11-16 14:46:00 +01:00
FredApps ceffcc52da Merge pull request #1846 from storytold/feature/craft-pe
Add craft-pe: PE/COFF headers from Craft Anything
2026-11-16 14:45:21 +01:00
FredApps 17afe46839 Merge pull request #1843 from storytold/feature/craft-tar
Add craft-tar: TAR and cpio member walkers from Craft Anything
2026-11-16 14:36:11 +01:00
Dylan M. TaylorandVoiceLessQ 6ef2c053df tiff: share allocation-free first-image compression probe (#1867)
* tiff: share WordCraft classic compression probe

Extracted from storytold/wordcraft crates/geom/src/picture.rs at fe8a8a838cde68b272ac68429e53049347feab40. Original implementation by VoiceLessQ; retains Dylan Taylor duplicate-tag hardening from ab0020d6f.

Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>

* tiff: cover compression probe refusal and endian parity

* test(tiff): allow assertions on bounded fixture conversions

---------

Co-authored-by: VoiceLessQ <t12kaem@gmail.com>
2026-11-16 08:19:29 -05:00
2f8b328c6f Add craft-elf: ELF program headers and dynamic entries from Craft Anything (#1851)
Moves the header pieces of Craft Anything's crates/formats/src/elf.rs
into a pure-Rust crate: the class/endian-aware reader, program_headers,
ProgramHeader, dynamic_entries, va_to_off, and the segment type,
permission and dynamic tag names. Mitigations, dynamic symbols, symbol
versions and core-file notes stay in the app.

Part of #778.

Co-authored-by: BFlat <bombayapirat@gmail.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Co-authored-by: GGWA <65288322+rech4210@users.noreply.github.com>
2026-11-16 08:18:20 -05:00
Dylan M. TaylorandAndy Ching 046a7229af fix(docx): integrate VML fallbacks without breaking linked text-box stories (#1864)
* craft-docx: write Word 2010 shapes inside mc:AlternateContent with a VML fallback

A shape was written as a bare `wps:wsp` in `w:drawing`. Word 2007, and
Word 2000-2003 with the Office Compatibility Pack, don't know `wps` and
refuse the whole file. Word writes such shapes in `mc:AlternateContent`.

`write_shape` now guards the drawing with `mc:Choice Requires="wps"` and,
for rectangles, text boxes, rounded rectangles and ellipses, adds an
`mc:Fallback` with the shape as VML: size, position, z-order, wrapping,
fill, outline and the text box's text (copied from the choice's output,
so the story isn't written twice). Other kinds get no fallback; an old
reader skips that shape and still opens the file.

Refs storytold/wordcraft#6849

* craft-docx: guard a shape only when it gets a VML fallback; keep more in the fallback

A shape guarded by `mc:AlternateContent` with no fallback is skipped by
a reader that doesn't know `wps`, and dropped on that reader's next save:
worse than refusing the file. Such shapes are written bare again; only
shapes with a VML form are guarded.

The VML fallback also keeps the shape's own stacking order (a floating
object in its text box moved `self.z` on), its wrap distances, its hidden
flag and its text box's text direction.

* craft-docx: keep behind-text shapes' order in the VML fallback

A behind-text shape's fallback `z-index` was the negated `z`, which
reverses the order of overlapping behind-text shapes. It is now `z`
shifted below zero within signed 32-bit range, so a higher `z` still
stacks higher; other shapes' `z-index` is capped at `i32::MAX`.

* fix(docx): preserve linked text boxes without an incomplete VML fallback

---------

Co-authored-by: Andy Ching <53651198+andyching168@users.noreply.github.com>
2026-11-16 08:16:40 -05:00
FredApps dd345db898 image-codecs: read a raster's resolution from its headers (resolution_probe) (#1838)
* image-codecs: read a raster's resolution from its headers (resolution_probe)

file_resolution(bytes) gives the pixels per inch a JPEG, PNG, WebP, BMP or
classic TIFF records without decoding pixels. JPEG uses the decoder's marker
scan (Photoshop, XMP, EXIF, then JFIF), PNG reads pHYs as the decoder does and
falls back to eXIf, WebP its EXIF chunk, TIFF its IFD0 tags; BMP reads the
info header's pixels per metre. Values outside 1-100000 ppi count as none.

DesignCraft (crates/images/src/resolution.rs) and FigCraft
(crates/format/src/density.rs) each carry their own marker and chunk walkers
for this; they can switch to the shared probe.

Part of #778 and #785.

* image-codecs: resolution_probe reads only a whole nine-byte pHYs, and a zero one leaves eXIf

A pHYs chunk that declares any other length, or is cut off before its
CRC, records nothing, and its data is no longer read from the bytes
after it. A zero pixels-per-metre count records nothing either, as in the
decoder, so the eXIf resolution still answers.
2026-11-16 08:14:38 -05:00
FredApps af8981f596 craft-drawingml: chart legend entries and engineering-format rounding from DeckCraft (#792) (#1871) 2026-11-16 08:13:29 -05:00
FredApps becf2a0a55 svg: recognise rectangles, rounded rectangles and ellipses in scene paths (#778, #789) (#1869)
tree::primitive::recognize (and Path::primitive) returns the axis-aligned
basic shape a path draws: one closed contour whose points all lie on a
(rounded) rectangle's or ellipse's outline and that encloses its area. usvg
turns rect, circle and ellipse into paths; apps that edit them as shapes get
them back from the segments.
2026-11-16 08:07:44 -05:00
Dylan M. Taylor 21ceafea04 fix(svg): validate declaration encodings and internal subset boundaries 2026-11-16 07:59:10 -05:00
FredApps 402dfe46ad raw: charge short lossy JPEG DNG strips their declared rows (craft-libs #778) (#1857) 2026-11-16 07:52:02 -05:00
FredApps 7888c863df svg: bound entity declaration scans and reset smooth controls after Z
#778, #789. Comments and CDATA are skipped, and a declaration name is
only scanned up to MAX_NAME+1, so a comment full of `<!ENTITYx` markers
is no longer a quadratic walk. Names longer than MAX_NAME are still
recorded so the expansion guard can refuse them. Closepath also clears
the smooth-control history, so S and T after Z start from the current
point rather than reflecting the pre-close control.
2026-11-16 13:51:42 +01:00
Dylan M. TayloranddotCooCoo a62de6c7c3 exr: integrate mixed deep/flat decoding with regression coverage (#1853)
* EXR: decode a flat part of a file that also holds deep parts

decode_part refused every part of a file with any deep part, and
decode_display_part, which checked only the selected part, still failed
because the exr crate's image reader validates every header and refuses
deep ones before it reads a chunk.

Both now decide from the selected part's own header. When any part is
deep, the selected flat part is read chunk by chunk: the flat headers are
validated, every part's offset table is walked from the end of the
headers, and only the selected table's chunks are read. A chunk must start
past the last offset table and inside the file, carry the selected part's
number and hold a block no other chunk of the part holds; anything else is
Malformed. Files with only flat parts keep the crate's reader.

The file-size ratio check, which was skipped for every part when any part
was deep, now applies to the flat parts of such a file; deep parts are not
counted.

* EXR: a flat part beside a deep part needs a chunk for each of its blocks

The chunk reader for a flat part of a file that also holds deep parts
refused only a second chunk for the same block. A tiled part's chunk that
named a level the part does not have was skipped without decompressing,
so the tile it took the place of had no chunk and the part decoded with
that tile left at zero.

Each chunk now has to hold one of the part's own blocks, taken from the
header, that no other chunk holds; anything else is Malformed. Since a
part has as many chunks as blocks, every block then has a chunk.

The mixed-file tests also run with a tiled flat part, and a new test
names a missing level and a repeated tile.

* EXR: a scan-line chunk beside a deep part must start at its block's first line

The block index of a scan-line chunk is its y offset divided by the
lines a block holds, rounded toward zero. A chunk whose y was not the
first line of a block, or lay up to 15 lines above the data window of
a ZIP part, still named a block and was decoded into it. Such a chunk
is now Malformed.

* EXR: a block too large to address is LimitExceeded instead of a panic

The exr crate bounds a flat chunk by a block's pixels times the bytes a
pixel takes, an unchecked product, before it reads the chunk. A 1 x 1
part with five float channels in 10^9 x 10^9 tiles passed every size
limit, and decode_part and decode_display_part then panicked with an
overflow, for files of flat parts only and for mixed files alike.
read_meta now computes the product with checked arithmetic for each
flat part and returns LimitExceeded when it does not fit in a usize.

* EXR: a chunk beside a deep part must fit the rest of the file

The exr crate allocates a chunk's declared payload, up to the size of a
block, before it reads it. In a mixed file whose flat part has large
tiles, a chunk declaring i32::MAX bytes made a 2 GiB allocation from a
file of a few hundred bytes. read_flat_part_chunks now reads the
declared length first and returns Malformed when it is longer than the
bytes left in the file.

* test(exr): verify mixed-part ratio and display block budgets

* fix(exr): bound mixed-part payload and block bookkeeping allocations

* fix(exr): expose internal ordinal helpers to regression tests

---------

Co-authored-by: dotCooCoo <RobertLeeLW@gmail.com>
2026-11-16 07:47:06 -05:00
FredApps 7ed3163f35 render-parity: a NaN tolerance fails its check instead of switching it off 2026-11-16 13:45:33 +01:00
FredApps 8e03cd016d craft-pdf: content streams (parse, serialize, matrices) from PDFCraft (#1852)
Adds the content feature and cos::content: PDFCraft's crates/content, moved
here so other apps can read and write page content streams. The parser keeps
operator spans, skips and counts unreadable bytes, and keeps inline images
whole; tests move with it.

Refs #778
2026-11-16 07:30:09 -05:00
FredApps dd80bb5bc5 Keep cached results for shadowed XLSB name references 2026-11-16 13:21:01 +01:00
FredApps 083920ebd7 psd: keep a layer record's blocks before an overlong one (#1845) 2026-11-16 07:19:08 -05:00
FredApps a80c0f25f1 ps: add a write feature for PostScript tokens (#778, #790) (#1840)
* ps: add a write feature for PostScript tokens

Numbers, strings, matrices, path data and Flate, so apps can emit a
PostScript or EPS program without owning the token serializer. Path and
paint operators can use the Language Reference names or the one-letter
names a bound prolog defines. Container concerns stay in craft-eps.

Part of #778 and #790.

* ps: tighten write-feature number trimming and Flate bounds

- Require flate2 1.1.10 so inflate rejects an incomplete zlib stream.
- Trim trailing zeros only when the token has a decimal point, so
  places=0 keeps integer zeros at the 1e15 boundary.
- Use saturating_add when bounding inflate, so max = u64::MAX does not
  overflow.
2026-11-16 07:12:00 -05:00
FredApps ddbe78231b craft-video: pass the packet's Adobe APP14 transform to the MJPEG decoder (#1847)
mjpeg::Decoder called craft_jpeg::decode with no Adobe transform, so a
packet with numeric component ids and APP14 transform 0 (RGB as stored)
was converted as YCbCr and came out in the wrong colours. The decoder
now reads the transform with craft_jpeg::adobe_transform, as the JPEG
image readers do. A regression test injects APP14 transforms 0 and 1;
it fails without the fix.
2026-11-16 07:10:48 -05:00
FredApps 431f704478 svg: let SvgWriter name the encoding and write a DOCTYPE subset (#778, #789) (#1842)
* svg: let SvgWriter name the encoding and write a DOCTYPE subset

VectorCraft's SVG document wrapper needs a Latin-1 declaration and a
<!DOCTYPE svg [ <!ENTITY …> ]> internal subset, including a minified
form with no extra newlines. The existing declaration was UTF-8 only,
and craft-xml's doctype helper writes only <!DOCTYPE name>.

Part of #778 and #789.

* svg: expose SvgWriter::as_str for a second pass on open markup

A consumer that rewrites character references or hashes the document
around a metadata element needs the text of an unclosed root. finish()
would close it first.
2026-11-16 07:04:35 -05:00
FredApps 9f46880bf5 Merge remote-tracking branch 'origin/main' into w1849
# Conflicts:
#	Cargo.toml
#	README.md
2026-11-16 13:01:00 +01:00
FredApps 48dcd1b472 Merge remote-tracking branch 'origin/main' into w1846
# Conflicts:
#	Cargo.toml
#	README.md
2026-11-16 13:00:41 +01:00
FredApps 57f94d5283 Merge pull request #1834 from andyching168/docx/wps-shape-vml-fallback
craft-docx: write Word 2010 shapes inside mc:AlternateContent with a VML fallback
2026-11-16 13:00:13 +01:00
FredApps 356c7ceb29 Merge remote-tracking branch 'origin/main' into w1843
# Conflicts:
#	Cargo.toml
#	README.md
2026-11-16 12:59:40 +01:00
FredApps b836a71856 craft-svg: a paths feature, and CSS colours with their alpha (#1848)
The geometry reader (craft_svg::paths) is the only part of the crate that
needs vectorcraft-geom and vectorcraft-pathops, and the tree is the only part
that needs craft-image-codecs. Both are now optional: paths is a default
feature and tree turns it on, so existing users build the same crate, while
an app that only needs SVG text, guards, path data, colours and the writer can
turn default features off and take no app crates or image codecs.

parse_color_alpha is parse_color keeping the alpha of #rgba, #rrggbbaa and
the fourth value of rgb()/hsl(). parse_color now calls it and still drops it.

Refs #778, #789
2026-11-16 06:54:06 -05:00
Dylan M. Taylor e409e74333 fix(print): opt-in bounded discovery for larger CUPS fleets (#1734)
* fix(print): allow explicitly bounded fleet discovery

* print: frame fleet discovery fixture as an HTTP reply
2026-11-16 06:49:02 -05:00
tsw2k 8b876291a1 craft-docx: a frame preset shape is a border with a hole
Moves the format part of storytold/wordcraft#6162 into craft-wordmodel,
craft-docx, craft-flow and craft-odf, where WordCraft's DOCX and ODT I/O now
live (#778).

A DrawingML `prstGeom frame` (a letterhead's page border) was read as a
rectangle, so its fill covered the whole page behind the text. It is now
ShapeKind::Frame, its border width read from `adj1` (capped, as a rounded
rectangle's corner is) and written back as the same preset.
connector::frame_width gives the border in points. Formats with no frame
shape (ODT and the other flow formats) get the freeform it draws: its
outline and, wound the other way, its hole, so the hole stays empty under
either fill rule.
2026-11-16 11:46:35 +00:00
tsw2k fe68ce8c51 craft-flow: narrow table columns keep their width on import
Moves the import part of storytold/wordcraft#4964 into craft-flow, where
WordCraft's RTF and ODT import now builds its tables (#778).

Import raised every column under 6 pt to 6 pt, so a form with many narrow
columns came out wider than its source. Columns over 1 pt now keep the
width the file gives; one of a point or less, none or not a number still
gives the table equal columns, so nothing below a point, negative or NaN
reaches layout.

craft-rtf merged grid columns under 6 pt that no row needed, because import
would widen them. With import keeping them, that merge only moved cell
edges, so it goes: grid columns merge only while there are over 63 or one
is a point or less.

Stacked on the craft-rtf column grid change.
2026-11-16 11:40:14 +00:00
FredApps 070005125f Add craft-sniff: name a file's format, media type and extension from its first bytes (#1841) 2026-11-16 06:38:32 -05:00
tsw2k 69d26616e0 craft-rtf: tables keep their column grid on odd rows
Moves storytold/wordcraft#4595 into craft-rtf, where WordCraft's RTF
reader now lives (#778).

column_grid dropped the whole grid, so every spanning cell fell back to one
of N equal columns, when a table had more than 63 distinct cell edges, a
zero-width cell, a cell without \cellx, or two edges under a point apart
(which the document model rejects as a column width). Forms exported from
spreadsheets, with many narrow columns, hit this: a report title wrapped a
few words per line in a quarter of the page and the document grew to
hundreds of pages.

Now the narrowest column merges into the next, one at a time, while there
are over 63 columns, a column of a point or less, or a column under 6 pt
with more columns left than the widest row has cells; each cell edge snaps
to the nearest grid edge, and a zero-width or undefined cell takes a column
in its own row only.
2026-11-16 11:35:07 +00:00