feat(anatomy): text and output caps, hostile corpus through the shipped wasm within budgets; SheetSession poisons on non-closed throws

This commit is contained in:
bchanot committed 2026-10-14 23:55:22 +02:00
1 parent 842797b440
commit 43a370aed1
8 files changed
+227 -6

No files matched your search

+8 -1
View File
@@ -150,6 +150,9 @@ const PRESENTATION_ATTRIBUTES: [&str; 27] = [
/// The engine's cap on `<use>` elements and on each `stdDeviation` number.
pub const MAX_USES: usize = 256;
pub const MAX_STD_DEVIATION: f64 = 100.0;
/// A `title` or `desc` text is a tooltip: longer is refused whole (never cut), so a text
/// node cannot inflate the composed view (`>` is written `&gt;`).
pub const MAX_TEXT_BYTES: usize = 4 * 1024;
const STYLE_FORBIDDEN: [&str; 5] = [
"expression(",
@@ -209,7 +212,11 @@ impl Walk {
element.children.push(Node::Element(child));
}
Node::Element(child) => self.removed.push(child.qname),
Node::Text(text) if keeps_text || is_xml_space(&text) => {
Node::Text(text) if is_xml_space(&text) => element.children.push(Node::Text(text)),
Node::Text(text) if keeps_text => {
if text.len() > MAX_TEXT_BYTES {
return Err(SvgRejection::TooComplex);
}
element.children.push(Node::Text(text));
}
Node::Text(_) => {}
+3 -2
View File
@@ -360,8 +360,9 @@ pub struct CanvasView {
pub svg: String,
}
/// A composed view larger than this is refused (plan R3 C2: output bounded).
pub const MAX_COMPOSED_BYTES: usize = 8 * 1024 * 1024;
/// A composed view larger than this is refused (plan R3 C2: output bounded; the product
/// drawing composes to 143 KiB).
pub const MAX_COMPOSED_BYTES: usize = 4 * 1024 * 1024;
fn view_canvas(sheet: &LoadedSheet, input: &str) -> Outcome {
let input: CanvasViewInput = parse_input(input)?;