Commit Graph
5343 Commits
Author SHA1 Message Date
Dylan M. TaylorandClaude Opus 5.5 1febfd1d31 Security: render and PDF export bounds for symbol expansion, dotted guides, blending groups and pinned images
CodeRabbit findings #32, #38, #41, #44, #102:

- A frame (and a PDF export) draws symbol instances holding at most 16M objects together
  (`vectorcraft_doc::MAX_SYMBOL_NODES`): nested instances multiplied past the depth limits.
- A dotted guide whose control polygon would make more than 100,000 dashes is drawn solid.
- Groups blending with their backdrop, drawn twice each, are drawn isolated past 4 nested.
- An image is decoded only while it and the images paints hold fit twice the decode allowance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:19:59 +07:00
NetterSilverandClaude Haiku 5.5 f8ad2edad8 Match !important case-insensitively in SVG import CSS parser
Found while testing crates/svg/src/import/css.rs:25

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 17:19:59 +07:00
Taha-Mahmoodi d3a01307ea PDF import: a string entered from many dictionaries in skipped text is read once
Review of #3924: in a flat area of ` <<(` (CMYK or RGBA 32, 60, 60, 40) in an uncompressed image, each `<<` after white space was read as a dictionary, and each read its string, which never ends, to 64 KiB past it: about 16 K bytes a pixel, so a few hundred bytes of it spent the budget and the file was refused.

Whether a byte in a literal string is escaped doesn't depend on where reading began (the run of `\` before it lies after any `(` before it), so the string from any `(` ends after the first `)` that takes the file-wide count of `(` less `)` below the count at that `(`. Those ends are found for the whole file in three linear passes the first time a string read in skipped text runs past 64 bytes: forward for the final count, back for the `(` whose string never ends, forward pairing the rest. Ends further than 64 bytes are kept (at most one for every 16 bytes of the file; a file built to nest past that is refused); nearer ones are read again. So entering a string costs at most 64 bytes, charged as one. A comment's end of line is kept for every comment read, not only the last.
2026-10-24 17:19:59 +07:00
Taha-Mahmoodi 2d5024bf82 PDF import: a run of "<" in skipped text no longer spends the pre-open scan's budget
Review of #3924: every `<<` in a string, comment or stream's data was read as a dictionary of its own, and in a run of `<` (an uncompressed image's flat area of grey 60) every position is one, each read to past the run, so about N²/2 bytes for N `<` and a 1 MiB run refused the file.

The reader starts a dictionary there only where its repair scan tries one (after white space or a dictionary's `>>`) or after an object's `N G obj`: so only those `<<` are read, in a run of `<` only the first. A reading goes on as far as 64 KiB past the last `<<` opened on the way, looks at each nested dictionary's `>>` for a stream and marks each `<<`, so it is not read again; a comment's end of line is kept, as many readings cross the same comment; the `<<<` second-`<` reading in the main pass goes (the reader never starts there). The dictionary text a stream check parses is charged to the budget.
2026-10-24 17:19:59 +07:00
Taha-Mahmoodi 1ec46732b8 PDF import: the pre-open stream scan doesn't let a "stream" inside a literal string hide the real stream after it
Review of #3919: the scan raised its walk-back floor at every `>>stream`, so one inside a literal string moved the floor past the `<<` of the cross-reference stream around it, and that stream was never looked at. The backward walk also counted a `>>` inside a string, and missed a comment between `>>` and `stream`.

The scan now reads the file forward once, as the reader does: literal strings (nested, escaped), hex strings and comments are skipped, `<<` and `>>` pair on a stack, and a dictionary followed by `stream` is a stream's, whose data is skipped. Because the reader can still start at a `<<` inside skipped text (a cross-reference offset or its repair scan), each such `<<` is read as a dictionary of its own, up to 64 KiB, within a budget of four times the file plus 1 MiB; a crafted file that spends it is refused. The scan stays linear.
2026-10-24 17:19:59 +07:00
Dylan M. TaylorandClaude Sonnet 5.5 a7910edd64 Review fixes: keep later CAD layouts, ordered-stop gradient sampling, skip full-stroke previews, cache shift line
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 17:19:59 +07:00
Dylan M. TaylorandClaude Opus 5.5 20bba9ebae Security: linear work for shortcut review, gradients, recovery names, include cycles, batch references, DOCX style ids, CAD layouts and long strokes
CodeRabbit findings #2, #16, #31, #103, #114, #124, #162, #179, #182, #183, #185:

- Shortcut import review: example names for each code in one pass over the rows.
- Gradients: a midpoint stop is mixed from its two stops; freeform recolor samples its
  increasing positions with one advancing search (`Gradient::sample_increasing_with`).
- Recovery: image entry names are looked up by address, and dead ones swept when the map
  doubles, not on every image.
- Script checker: include cycles from strongly connected components (iterative Tarjan), not
  a reachability row per file.
- Batch step references copy at most 256 MB of values for one step.
- DOCX: style ids over 256 bytes are ignored where defined and where used.
- DXF: layouts keep at most 4 MB of names; a hatch's loops count against the node limit.
- Freehand and Liquify: past 1000 samples a drag previews every n/1000 samples, strokes keep
  at most 100,000 samples, and the stroke kept is previewed in full before it is committed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:19:59 +07:00
Dylan M. TaylorandClaude Opus 5.5 bc56851904 Security: bring Read into scope for the bounded link hash
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:19:59 +07:00
Dylan M. TaylorandClaude Opus 5.5 03d2f0e83c Security: file authority for stored paths, linked files, placed documents, font folders, recovery areas and atomic saves
CodeRabbit findings #7, #72, #92, #94, #95, #99, #100, #140, #158, #174:

- Link search hashes at most the size it looked at (a growing file no longer matches).
- Resolving links reads, decodes and previews each linked file once, shared by every key.
- Placed documents read inside one another resolve links at most 8 deep, never one already
  being read.
- A data set's image path and the placed-document rereader follow stored paths through
  `document_path` (no other computer's share).
- The Links panel looks at a linked file within the roots of the automation caller that
  opened the document.
- A fonts folder set by a confined caller is scanned without following links out of it.
- Recovery refuses an area folder that is a link or another account's.
- Atomic saves keep the replaced file's group and Linux access ACL, or make the replacement
  owner-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:19:59 +07:00
bflatastic 8a73ed9963 Security bounds: fix on landing #3936 (see the PR comment) 2026-10-24 17:19:58 +07:00
Dylan M. TaylorandClaude Opus 5.5 e2a870e602 Security: bounded flattening, plug-in budgets and caches, loaded textures, Revolve paint copies, color book names and ICC names
CodeRabbit findings #4, #34, #46, #51, #77, #101, #170, #171, #188:

- `vectorcraft_geom::flatten`: kurbo's flatten with each curve's tolerance raised so it makes
  at most ~4096 segments (non-finite curves become a line); the canvas outline and
  variable-width strokes use it.
- Plug-ins: a heavy filter's budget is the host's `Limits::heavy_fuel`/`heavy_wall_time_ms`,
  never more; a start function runs on one fuel slice; the effect cache holds at most ~1M
  anchors of inputs and results, and doesn't keep a result past a quarter of that.
- Loaded textures are cached by their PNG (base64 spacing doesn't matter), and live textures
  hold at most 512 MB together.
- Revolve draws the source path when the faces' paint copies would pass 256 MB.
- Color books: names with prefix and suffix take at most 64 MB.
- ICC: localized-name (`mluc`) records over 1 MB together are refused before moxcms copies them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:19:54 +07:00
bflatastic a608838ba2 Security bounds: fix on landing #3939 (see the PR comment) 2026-10-24 17:19:54 +07:00
Dylan M. TaylorandClaude Opus 5.5 b12ee928f3 Security: document model generation budgets for live art, clipping runs, placed documents, graph masks, path reading and native entries
CodeRabbit findings #58, #75, #82, #113, #159, #175, #187:

- Live evaluation (expansion, envelope mapping and everything inside) makes at most 4M
  objects (`MAX_GENERATED`); deep expansion counts what each live object makes, and envelope
  image pieces count before they are cut.
- Clipping runs copy at most 8M clip path elements together; past it runs are plain groups.
- Exports read at most 256 placed documents; the rest show their previews.
- Graph design and marker budgets count opacity-mask art (`Node::count_with_masks`).
- Native files read at most 32M anchors (4M on wasm) of paths; the web build allows 1 GiB of
  entries after the JSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:19:16 +07:00
aiongg 75dacb4fec Build: craft-pdf, hayro and krilla at craft-libs 2eca9b3a, with hayro-postscript from craft-libs (#3957)
hayro-postscript now comes from craft-libs' vendored copy, whose token scanner skips << and >>
runs without recursion, instead of crates.io 0.1.0. The rev also brings the reader input bounds
and crash fixes from craft-libs #257 and #261. The pdf-deps check requires hayro-postscript from
craft-libs; ASSETS.md, NOTICE and docs name the new rev. The asset hashes are unchanged.
2026-10-24 04:07:00 -04:00
aiongg 41c765e984 Build: craft-pdf, hayro and krilla at craft-libs main (#3931)
* Build: craft-pdf, hayro and krilla at craft-libs main

Picks up the input bounds that landed after ca50d63b: zero-width xref streams, the JBIG2
referred-to segment count, the graphics-state stack depth and decoded PNG sizes.

* Build: craft-libs 9f75d3dc, with hayro-cmap from craft-libs

Adds the /W2 CID-width bound (#254) and takes hayro-cmap from craft-libs' vendored copy,
which skips malformed CMap parts, instead of crates.io 0.1.0.

* Build: the pdf-deps check, ASSETS.md, NOTICE and docs name craft-libs 9f75d3dc

The check also requires hayro-cmap from craft-libs. The asset hashes are unchanged.
2026-10-24 03:05:17 -04:00
Dylan M. Taylor 50d976e1e6 style: keep paint.rs spot-colour chain under rustfmt's max width (#3940)
* style: wrap long spot-colour fallback chain to satisfy rustfmt

* fix(brush): replace negated partial-ord comparison (clippy 1.99)
2026-10-24 02:03:48 -04:00
Dylan M. Taylor 4c82749b08 Security: Affinity import and brush expansion bounds (#3887)
* Audit: Affinity import (spot colour chain, zero-width records, corner radii)

* Audit: Affinity layer names are cut at 1024 characters

* Audit: brush expansion bounds (masks, library parsing, flattening), pressure profile lookup

* Brush: reach a node's mask through its extras
2026-10-23 22:43:42 -04:00
BFlat c8c005b7f3 Merge pull request #3932 from storytold/feat/852-macos-pen-pressure
macOS: a tablet pen's pressure reaches the tools (#852)
2026-10-24 09:42:34 +07:00
BFlat 8808019ce2 Merge pull request #3935 from storytold/fix/main-clippy-bitmap
Main's CI: an unnecessary map_or, testkit's Unix-only mut, and a shared temp-dir probe
2026-10-24 09:42:18 +07:00
Dylan M. Taylor 6c05c10fff chore(text): use is_some_and instead of unnecessary map_or (clippy) (#3929) 2026-10-23 22:39:51 -04:00
Dylan M. Taylor 76467a1a9b ci: move release workflow write permission to job level (SonarCloud S8233) (#3928) 2026-10-23 22:37:12 -04:00
bflatastic 8dbca35893 macOS pen pressure: a feed written on the UI thread never waits for a touch 2026-10-24 09:26:27 +07:00
bflatastic b1e36d69f3 macOS: a tablet pen's pressure reaches the tools (#852)
An AppKit local event monitor (apps/vectorcraft/src/mac_tablet.rs) reads each mouse and tablet event's pressure and the pen's end before winit's view handles it and writes them into the canvas's StylusFeed. The feed keeps the pressure of each pointer move, and the canvas pairs them with the frame's moves, so a fast stroke keeps its curve and each point its own pressure; mouse event coalescing is off. The eraser end selects the Eraser tool, as on Linux. Ported from PhotoCraft's crates/tablet (pressure and eraser end only).
2026-10-24 09:26:27 +07:00
bflatastic e219543e58 Main's CI: an unnecessary map_or, testkit's Unix-only mut, and a temp-dir probe that tests running alongside removed 2026-10-24 09:26:06 +07:00
BFlat 90c1f8d196 Merge pull request #3927 from storytold/fix/1479-ai-large-images
.ai import: an image too large for the editing data's reader opens the file as its PDF part, not with a blank layer (#1479)
2026-10-24 08:55:42 +07:00
Dylan M. Taylor d1288e3019 Security: text layout, shaping, font name and embedding bounds (#3880)
* Audit: text layout, shaping, fonts and embedding bounds

* Audit: text bitmap chunk walk without overflow

* Test: PNG metadata chunk walk

* Security: keep the word minimum in wrap regions; allow uncompressed iTXt text

A wrap shape can narrow the first baseline of a rectangular region:
place_at_least then relaxed the minimum to 0 (the region still counted as
"all lines equally wide") and picked the narrow span, breaking a word on
that baseline even though a lower one had room for it whole. Treat the
width as constant only when the region has no wrap shapes.

Also, PNG iTXt chunks may be stored uncompressed: only genuinely
compressed text (flag 1, conservatively anything that does not parse)
counts as compressed metadata now.
2026-10-23 21:53:51 -04:00
Dylan M. Taylor dad86afeee Security: private temp paths for the signing certificate and test output; web font licences stay inside the checkout (#3871)
* Audit: private temp paths for the signing certificate and testkit output; confine web font licences to the checkout

* testkit: refuse a pre-made private temp directory this user cannot write to
2026-10-23 21:52:17 -04:00
Dylan M. Taylor 2541fd8efd Audit: Image Trace bounds (mosaic duplicate tiles and short buffers, overflow-safe raster length, grouping and centerline work caps) (#3878) 2026-10-23 21:52:11 -04:00
bflatastic 76c9aa579d .ai import: an image too large for the editing data's reader opens the file as its PDF part, not with a blank layer (#1479) 2026-10-24 08:39:00 +07:00
aiongg 8cc69ed45c CI: one test binary per crate, nextest, line tables only (#3855)
* CI: line tables only for workspace crates, no debug info for dependencies

* CI: one integration-test binary per crate

Each crate's tests/*.rs files become modules of tests/it/main.rs. Files that change
process-wide state (Color Settings, the font database, installed plug-ins, the working
directory), the fuzz sweeps and the test targets the Affinity corpus workflow names stay
their own binaries.

* Docs: name the integration tests' new paths

* CI: xtask test with nextest and doctests, one wasm check, clippy --keep-going

cargo xtask ci runs the tests with cargo nextest (cargo test when it is not installed),
builds them with --lib --bins --tests, runs the doctests as their own step, and checks
the wasm crates in one cargo check --keep-going call.
2026-10-23 21:36:10 -04:00
BFlat 5037a1ac4b Merge pull request #3923 from storytold/land/3922
G11: Shape Builder pieces: contract the sweep's stubs between two cuts of one path
2026-10-24 08:18:12 +07:00
Angelo BernardiniandClaude Opus 5.5 e11ff0352b G11: Shape Builder pieces: contract the sweep's stubs between two cuts of one path
Where two passes of a path (an open line's way there and back) cross another
path, the sweep can cut them a rounding error apart and join the two cuts
with a stub a little over its tolerance. Upstream's twin-piece joining
already merges the ends of the two passes, but not such stubs, so dense
hatches at exact binary steps (lines every 0.5 pt across a 45° line) still
came back with a speck of a piece per crossing. The planar map now contracts
such stubs into one vertex before the edges are built (within 4x eps up and
down the sweep's frame and 1/16 of the 0.01 pt precision along it), bounded
by each cluster's extent so a run of tiny, nearly level segments (a finely
flattened or traced path) is not collapsed transitively.

Ported from the fork's d5985b14 and 616a5c4a with their tests:
a_dense_hatch_at_exact_binary_steps_cuts_each_line_once_per_crossing (fails
without the fix), a_run_of_tiny_level_segments_is_not_contracted_as_stubs
(fails without the extent bound) and
a_line_crossed_where_its_two_passes_part_is_cut_once (already passing on
upstream, kept as a regression test).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014gCpjL3yUhaH3jRp7ksufh
2026-10-24 08:05:47 +07:00
aiongg c204d8959e CI: run the gate through craft-common-actions' shared gate.yml; FreeBSD nightly and on release (#3772)
ci.yml is new: it calls the shared workflow (cached apt packages, nextest, main-only cache saves, Cargo.lock check). FreeBSD and Windows ARM64 run nightly and on pushes to release instead of on pull requests. Depends on storytold/craft-common-actions#69.
2026-10-23 20:59:43 -04:00
BFlat f2d793f746 Merge pull request #3921 from Taha-Mahmoodi/fix/font-family-load-race
Fix #3920: a family another thread is loading is found whole, so fallback text never takes the style of its first file
2026-10-24 07:56:41 +07:00
Taha-Mahmoodi 6b52e54a1b Fix #3920: a family another thread is loading is found whole, so fallback text never takes the style of its first file
An installed family was added to the font database one file at a time, so a
lookup on another thread could find it with only some of its styles: text
falling back to Arial took Arial Bold Italic or Bold (its files sort first)
for upright Regular text, and the same text laid out a moment later took
Arial Regular. One Arabic word could even mix the two. Two threads loading
the same family could also add a face twice.

A family's files are now read and parsed first and their faces added under
one lock, skipping faces another thread added meanwhile. Loading a family
reports it loaded when another thread loaded it meanwhile, so the fallback
search doesn't go on to other families.

This made tests_bidi::a_change_of_paint_in_a_mixed_direction_line_moves_no_glyph
fail intermittently when another test loaded Arial at the same time.
2026-10-24 07:44:14 +07:00
BFlat 533cbc6b94 Merge pull request #3919 from Taha-Mahmoodi/fix/3586-pdf-stream-scan-linear
Fix #3586: the PDF pre-open scan reads a file dense with stream keywords in linear time
2026-10-24 07:35:21 +07:00
Taha-Mahmoodi ea55f89c24 Fix #3586: the PDF pre-open scan reads a file dense with stream keywords in linear time
Each `stream` keyword walked back up to 64 KiB through every dictionary before it, so 1 MiB of `<</A <</B 1>> >>stream` took minutes. A walk back now stops where the previous keyword's walk began, and a stream without a Length shares the search for the next `endstream`.
2026-10-24 07:35:07 +07:00
BFlat cdd3b949ba Merge pull request #3918 from lehni/fix/svg-glyph-image-href
Type: an SVG glyph's image is an SVG image by its plain href first
2026-10-24 07:23:53 +07:00
BFlat 180e6dc08c Merge pull request #3917 from Taha-Mahmoodi/fix/3828-japanese-business-card
Fix #3828: New Document › Branding offers Business Card 91 × 55 mm
2026-10-24 07:23:37 +07:00
Jürg Lehni deb517fbbe Type: an SVG glyph's image is an SVG image by its plain href first
The check for images of SVG documents looked at href and xlink:href alike, so an image whose href is a PNG was cut for an SVG xlink:href; it now reads href, else xlink:href, as the importer does (SVG 2).
2026-10-24 07:12:16 +07:00
Taha-Mahmoodi 767f06b20e Fix #3828: New Document › Branding offers Business Card 91 × 55 mm 2026-10-24 07:12:16 +07:00
BFlat 768f6ba523 Merge pull request #3916 from lehni/fix/svg-glyph-svg-images
Type: SVG glyphs leave out images of SVG documents
2026-10-24 07:02:17 +07:00
Jürg Lehni 4d1b4a3392 Type: SVG glyphs leave out images of SVG documents
The importer expanded an image whose data is an SVG document into art; the SVG table asks for it to be ignored, and a glyph draws no documents inside it.
2026-10-24 06:51:20 +07:00
BFlat 3aa9855010 Merge pull request #3914 from storytold/fix/flaky-nativemenu-test
Tests: native-menu tests count menu reads only in runs no other test disturbed
2026-10-24 06:39:52 +07:00
bflatastic 3fd190f747 Tests: native-menu tests count menu reads only in runs no other test disturbed 2026-10-24 06:26:02 +07:00
BFlat 0df73f7c36 Merge pull request #3907 from el-j/fix/direct-selection-fill-occlusion
M2.1: prevent click-through on open path fills and support segment toggle (#3405)
2026-10-24 06:23:32 +07:00
BFlat 09ad7e4e59 Merge pull request #3908 from lehni/fix/svg-glyph-images
Type: images in SVG glyph documents draw with the glyph
2026-10-24 06:23:18 +07:00
BFlat 07eb827be9 Merge pull request #3904 from Silvertree2010/fix/h1831-page-range-parser-accepts-a-lead
Reject a leading plus sign in page range numbers
2026-10-24 06:23:02 +07:00
BFlat 1e26801e4e Merge pull request #3905 from storytold/feat/3849-pdf-tiling-patterns
PDF export: pattern fills are written as tiling patterns (#3849)
2026-10-24 06:22:45 +07:00
BFlat d21e734d88 Merge pull request #3906 from storytold/fix/flaky-font-tests
Tests: engine tests that add fonts to the shared font database take one lock
2026-10-24 06:22:29 +07:00