Commit Graph
65 Commits
Author SHA1 Message Date
Dylan M. Taylor a6d5f86ee4 svg: pin transform composition and malformed-list parity 2026-11-16 23:22:03 -05:00
Altynzhan KarybaiandBrandon Thomas 399ecc74de svg: share bounded compatibility transform parsing
Preserve EffectCraft source from 4035d181329e847d7a57bf3d059502ea2c91b560, based on Brandon Thomas original 94e1c86d89a866771f80ad1610afda9aa12e85d8. Algorithm unchanged; module imports only adapted.

Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-11-16 23:21:07 -05:00
Dylan M. Taylor af9985523a svg: share bounded prefix-preserving kurbo path parsing (#1972) 2026-11-16 22:37:02 -05:00
Dylan M. Taylor 54715d0b92 svg: share precision-preserving legacy colour parsing (#1971) 2026-11-16 21:18:37 -05:00
Dylan M. Taylor 006ed3d965 svg: share bounded simple stylesheet parsing and matching (#1968) 2026-11-16 20:46:05 -05:00
dotCooCoo 77505bb715 craft-svg: a bracket in an element declaration does not end the subset
XML readers skip an element, attribute list or notation declaration to its
first `>`, quotes and brackets included. The guard's scans now end these
declarations the same way. A `]` inside `<!ELEMENT svg ] >` no longer ends
the internal subset for `too_wide` and `prescan`, and a `[` in one no longer
lets a later `<!--` hide the entity declarations after it from `declared`.
2026-11-16 12:02:58 -08:00
dotCooCoo 01fcf22cb0 craft-svg: comment markers in a declaration's literal hide no later declaration
declared() skipped a comment or CDATA section wherever `<!--` or
`<![CDATA[` appeared, including inside an entity's quoted value, another
declaration's literal or a processing instruction. With
`<!ENTITY c "<!--">` before a large entity, the scan skipped to the end
of the file, the large entity was never recorded, and
entities_expand_past let its references through to the XML reader.

- declared() reads a declaration's quoted literals and a processing
  instruction as text: a comment or CDATA marker there starts nothing,
  and the declarations after it are still read.
- prescan() counts the markup in an entity's value the same way, and a
  comment, CDATA section or instruction that closes inside the value
  still opens and closes no element.
- too_wide() and prescan() find the end of the internal subset past
  quoted literals, comments and instructions, so a `]>` in a value no
  longer ends the document type early.
2026-11-16 11:23:53 -08:00
FredApps 209a40d66c craft-svg: floor declared() name window to a character boundary (#1899)
* svg: floor declared() name window to a character boundary

If the MAX_NAME+1 cut split a UTF-8 character, get(..bound).unwrap_or(rest)
fell back to scanning the entire suffix. Floor the window instead, and
when recording an overlong name extend to the next character boundary so
the key is still longer than MAX_NAME.

* test(svg): assert declared() keys stay bounded after a multibyte cut

The overlong-name refusal alone also passed on the old unwrap_or(rest)
fallback, which recorded the whole suffix. Bound recorded keys to
MAX_NAME+4 so the test fails if the suffix is stored again.
2026-11-16 11:45:10 -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
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 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 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
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 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 f44195aa11 Reject damaged later SVGZ members 2026-11-15 18:12:18 +00:00
Dylan M. Taylor c4c4547b7b Merge pull request #1602 from storytold/codex/svg-neutral-document
Share streaming SVG primitives and drawing output
2026-11-15 12:10:47 -05:00
Dylan M. Taylor 9eb96c47e0 Merge pull request #1199 from storytold/codex/craft-svg-photo-preflight
Expose shared SVG preflight and viewport rewrite
2026-11-15 11:49:35 -05:00
Dylan M. Taylor 89cbc41650 Satisfy SVG reader clippy gate 2026-11-15 15:22:39 +00:00
Dylan M. Taylor 6c22881fc1 Share streaming neutral SVG geometry and output 2026-11-15 15:16:39 +00:00
Dylan M. Taylor 38c26217b1 Support fixed-precision SVG scene coordinates 2026-11-15 15:01:28 +00:00
FredApps cec6e24381 Check the rewritten SVG viewport output under the same limits 2026-11-15 15:52:47 +01:00
FredApps 4f6e49b1ee Test SVG preflight depth and root viewport rewrite; accept px root sizes
Correct the source-depth expectations (svg>g>path is 3 levels, 2 open), cover
Preflight and every rewrite_root_viewport refusal, and read a root width or
height written with px as the pixels the docs promise.
2026-11-15 15:13:06 +01:00
FredApps 3bfe94538b Merge main into codex/craft-svg-photo-preflight
The base this branch was stacked on has landed separately: #1187 through #1182,
and #1198 through #1331 and #1465. Take main for everything outside crates/svg
so this PR carries only the SVG preflight and viewport rewrite.

In crates/svg, keep main's root_unitless_size, embedded data-URL and text-size
accounting, and check_document, now on top of the shared preflight. Embedded
SVGs still charge the reference-following height to the shared depth budget,
as on main, rather than the source depth.
2026-11-15 15:13:00 +01:00
Dylan M. Taylor d594b6763b fix(svg): use normalized data URL error accounting 2026-11-15 04:32:18 -05:00
Dylan M. Taylor 586041bb68 fix(svg): preserve omission accounting on malformed data 2026-11-15 04:30:16 -05:00
Dylan M. Taylor 4e9b3e9fdd fix(svg): account for invalid embedded image data 2026-11-15 04:11:43 -05:00
Dylan M. Taylor 727f945fc9 Merge branch 'main' into codex/format-adapter-safety 2026-11-14 20:11:50 -05:00
Dylan M. Taylor 465fa74789 fix(metadata,raw,svg): address CodeRabbit review findings 2026-11-14 21:31:04 +00: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
Terra854 58ef208c13 fix: preserve RAW identity and SVG byte-limit reporting 2026-11-15 03:49:35 +08:00
Terra854 d61afc4a3b fix: preserve bundle commits and expose SVG resource refusals 2026-11-14 17:53:32 +08:00
Dylan M. Taylor e58cd131af test(svg): use tree-depth limit for referenced depth 2026-11-14 05:17:03 +00:00
Dylan M. Taylor fd708734aa Merge pull request #1182 from storytold/codex/photocraft-file-caps
Add shared format capability catalog
2026-11-13 22:38:59 -05:00
Dylan M. Taylor 344dbef231 Test SVG preflight limits and classify bad embedded SVG 2026-11-13 09:31:49 -05:00
Dylan M. Taylor 3eae15e8ec Expose bounded unitless SVG viewport metadata 2026-11-13 09:31:49 -05:00
Dylan M. Taylor 330280203c Reuse bounded preflight for embedded SVG 2026-11-13 09:31:49 -05:00
Dylan M. Taylor 81bd633c7f Expose checked SVG preflight and viewport rewrite 2026-11-13 09:31:49 -05:00
Dylan M. Taylor c5fae05a5a Merge remote-tracking branch 'upstream/main' into codex/craft-svg-photo-1171-sync
# Conflicts:
#	Cargo.lock
2026-11-13 08:55:10 -05:00
Dylan M. Taylor b5dfdb0bda Fix shared file import edge cases 2026-11-13 07:50:09 -05:00
Dylan M. Taylor f4f48a9ac2 Make open clip fixtures explicitly stroked 2026-11-13 07:36:18 -05:00
Dylan M. Taylor ee548f530c Avoid unused fill contour flag 2026-11-13 07:36:18 -05:00
Dylan M. Taylor 2a8bb6a4e3 Harden neutral vector import and shared output 2026-11-13 07:36:18 -05:00
Dylan M. Taylor 62e2328905 Add shared neutral file import and writer registry 2026-11-13 07:36:18 -05:00
Dylan M. Taylor 59c52ac1dc Merge pull request #1174 from dylanmtaylor/codex/vector-file-imports
Add shared vector path import APIs
2026-11-13 07:35:46 -05:00
Dylan M. Taylor a07481b416 Bound EXR pixel area and SVG image recursion 2026-11-13 06:27:24 -05:00
Dylan M. Taylor 365bf47db6 Expose bounded SVG root dimensions 2026-11-13 06:08:48 -05:00
Dylan M. Taylor dec78a5c40 Split SVG source and expanded-tree depth limits 2026-11-13 06:01:21 -05:00
Dylan M. Taylor 490884beec Add shared SVG subtree render handles 2026-11-13 05:48:22 -05:00