mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-14 06:22:24 +00:00
* craft-svg paths: a shape carries the name of its Inkscape layer Shape::layer is the inkscape:label (else the id) of the innermost <g inkscape:groupmode="layer"> around the element, so a CAD or cutter import can keep the drawing's layers. * craft-svg guard: bound attributes per element and over the document; find entities holding markup too_wide is the attribute check of storytold/figcraft#2251: an XML reader checks each attribute against the earlier ones on its element, so an element with millions of them is quadratic work before any other limit applies. entity_holds_markup lets a caller refuse a document type whose entities become elements, as PhotoCraft does. * craft-svg: feature `tree`, usvg behind one bounded entry point usvg 0.48.1 (Apache-2.0 OR MIT), re-exported as craft_svg::tree::usvg, so every app parses with one version and one set of checks: tree::parse runs svgz, the entity, attribute and nesting guards, the reference-chain height (VectorCraft's depth::height, on this crate's cascade), then usvg. tree::image_resolver bounds embedded SVGs (FigCraft's budget::resolver). tree::draw bounds what drawing a tree with resvg allocates (PhotoCraft's svg/limits.rs). Part of #778 and #789.
28 lines
1.3 KiB
Rust
28 lines
1.3 KiB
Rust
//! SVG: the one place the Craft apps' SVG format code lives.
|
|
//!
|
|
//! - [`sniff`]: is this an SVG, or a gzip-compressed one (SVGZ)?
|
|
//! - [`svgz`]: SVG text from the bytes of a file: SVGZ unpacked within a byte limit, UTF-8,
|
|
//! UTF-16 and ISO 8859-1 decoded; and SVGZ compression.
|
|
//! - [`guard`]: checks on the text before any XML reader or SVG converter sees it: how deep the
|
|
//! elements nest, and what the document type's entities expand to.
|
|
//! - [`paths`]: the geometry of a document as Bézier paths in millimetres, for cutters, plotters
|
|
//! and CAD import.
|
|
//! - [`color`]: CSS colours.
|
|
//! - [`write`]: a writer for SVG documents, their path data and numbers.
|
|
//! - `tree` (feature `tree`): the full parser. usvg at the one version the Craft apps share,
|
|
//! re-exported, behind an entry point that runs the checks above before it parses.
|
|
//!
|
|
//! Input is treated as hostile throughout: every size, count and depth is bounded, and a file
|
|
//! past a bound is an error, never a panic or an unbounded allocation.
|
|
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
|
#![forbid(unsafe_code)]
|
|
|
|
pub mod color;
|
|
pub mod guard;
|
|
pub mod paths;
|
|
pub mod sniff;
|
|
pub mod svgz;
|
|
#[cfg(feature = "tree")]
|
|
pub mod tree;
|
|
pub mod write;
|