Files
FredAppsandDylan M. Taylor 4a75c49e3b refactor(svg): read SVG text and path data through craft-svg (#386)
* refactor(svg): read SVG text and path data through craft-svg

SVG import now decodes its bytes with craft-svg (SVGZ, UTF-16 and Latin-1,
within the shared size limit) and refuses entity bombs, very wide elements
and deep nesting with craft-svg's guards before anicraft_xml builds a tree.

Path data (SVG import, the path.d and motion path commands, the interface
icons) is read by craft_svg::path_data. anicraft-geom keeps only the
elliptical-arc-to-cubic geometry; its own tokenizer is removed.

craft-svg is pinned to craft-libs main 57288eda.

Refs storytold/craft-libs#778, storytold/craft-libs#789

* refactor(svg): pin craft-svg to #1848 and parse colours through it

craft-svg is now at craft-libs main b836a718 (#1848), with default features
off, so the lock no longer pulls vectorcraft or the image codecs. Colours
go through parse_color_alpha; transparent stays in the app because the
shared parser rejects it. Percentage rgb channels follow the shared
parser's 8-bit rounding (50% is 128/255).

* fix(svg): clip out-of-range rgb() and bound decoded text

parse_color_alpha rejects rgb(300,0,0); CSS clips that to red, and so
did the previous local parser. If the shared parser fails, clip rgb()
channels and try once more. Also refuse text that grows past the 64 MiB
limit after Latin-1 or UTF-16 decoding, which svgz::text does not count.

* refactor(svg): pin craft-svg to #1878

craft-svg is now at craft-libs main c7a872e2 (#1878), which bounds the
entity-declaration scan and resets smooth-control history after Z.
default-features stays false. The other craft-libs pins are unchanged.

* fix(svg): bound rgb() components and emit integer channels

clipped_rgb now stops at a fifth component instead of collecting an
unbounded comma list, and number-form channels are retried as integers
so a value such as 127.5 is accepted by the shared parser.

* fix(svg): finish parser routing and reject missing moveto

Route the newer Continue Path entry point through the shared adapter. Require an initial moveto and assert precise preflight refusal variants. Focused geom/SVG tests: 137 + 31 passed. Quadratic gradient parity remains a separate merge blocker.

---------

Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
2026-11-18 15:14:56 -05:00
..