fix(anatomy): V1-2.2 read url() references in their strict spelling only
Security review BLOCK(1): url(#%61) passed the dangling check and the per-view scoping and resolved in browsers. One strict reading now, other spellings are active content; glued names are other functions; the composer refuses an unscoped reference; owner export procedure.
This commit is contained in:
1 parent
5281337412
commit
a678faaa23
13 files changed
+553
-70
No files matched your search
@@ -337,6 +337,78 @@ fn the_vector_tool_exports_are_read_or_refused_for_their_raster() {
|
||||
assert_eq!(raster.active, ["image"]);
|
||||
}
|
||||
|
||||
/// Security review of the arbitrations (2026-10-29): a `url(` is kept only when its target is
|
||||
/// `#` and an id in the reference grammar, an optional matching quote and `)`; every spelling
|
||||
/// a browser would normalise or read otherwise is active content, so the dangling check, the
|
||||
/// per-view scoping and the expansion budget cannot be walked around. Names glued to `url(` or
|
||||
/// `rgb(` are other functions, removed.
|
||||
#[test]
|
||||
fn every_url_spelling_but_the_strict_one_is_refused() {
|
||||
let svg = |value: &str| {
|
||||
format!(
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 10 10\">\
|
||||
<linearGradient id=\"a\"/><path d=\"M0 0\" fill=\"{value}\"/></svg>"
|
||||
)
|
||||
};
|
||||
for value in [
|
||||
"url(#%61)",
|
||||
"url(#%66v.main.a)",
|
||||
"url(\'#\ta\')",
|
||||
"url(\'#a\tb\')",
|
||||
"url(#)",
|
||||
"url(# a)",
|
||||
"url(\'#a)",
|
||||
"url("#a\')",
|
||||
"url(#é)",
|
||||
"url(#1a)",
|
||||
"url(#a b)",
|
||||
"url(#a rgb(1,2,3))",
|
||||
"url(#/a)",
|
||||
"url(#a",
|
||||
] {
|
||||
let cleaning = clean_svg(svg(value).as_bytes());
|
||||
assert_eq!(
|
||||
outcome(&cleaning),
|
||||
(Rejected, Some("svg_active_content")),
|
||||
"{value}"
|
||||
);
|
||||
assert_eq!(cleaning.active, ["path@fill"], "{value}");
|
||||
}
|
||||
for value in [
|
||||
"url(#a)",
|
||||
"URL( \'#a\' )",
|
||||
"url("#a")",
|
||||
"url(\n#a)",
|
||||
] {
|
||||
assert_eq!(
|
||||
outcome(&clean_svg(svg(value).as_bytes())),
|
||||
(Clean, None),
|
||||
"{value}"
|
||||
);
|
||||
}
|
||||
for value in [
|
||||
"érgb(1,2,3)",
|
||||
"rgurl(#a(1,2,3)",
|
||||
"xurl(#a)",
|
||||
"rgb(1,2,3)rgb(4,5,6)",
|
||||
"rgb(1,2,3)x",
|
||||
] {
|
||||
let cleaning = clean_svg(svg(value).as_bytes());
|
||||
assert_eq!(outcome(&cleaning), (Cleanable, None), "{value}");
|
||||
assert_eq!(cleaning.removed, ["path@fill"], "{value}");
|
||||
}
|
||||
// The expansion budget holds whatever the spelling: 250 000 references written `%61` are
|
||||
// refused as active content, as the plain spelling is refused as too complex.
|
||||
let flood = format!(
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\"><linearGradient id=\"a\"/><path d=\"M0 0\" fill=\"{}\"/></svg>",
|
||||
"url(#%61) ".repeat(25_000)
|
||||
);
|
||||
assert_eq!(
|
||||
outcome(&clean_svg(flood.as_bytes())).1,
|
||||
Some("svg_active_content")
|
||||
);
|
||||
}
|
||||
|
||||
/// Real Inkscape 1.4.3 exports (owner go 2026-10-29; `exports/generate-inkscape.sh`): its
|
||||
/// editor metadata and namespaces and the `text` it keeps as text are removed and named, so
|
||||
/// each is cleanable; shapes, gradient, clip path, internal references and colours stay; the
|
||||
|
||||
Reference in new issue
Block a user