fix(anatomy): V1-2.2 glued url( removed everywhere, Figma exports, mask units
The reader removes any attribute holding a url( that url_openings does not read, so reader, verdict, preview, canvas and PDF view accept the same drawings. maskUnits, maskContentUnits, clipPathUnits allowed with their two keywords (owner go). The owner's two raw Figma exports committed as fixtures with fixed expectations.
This commit is contained in:
1 parent
98060d74a3
commit
7d9ab8cf2f
11 files changed
+299
-13
No files matched your search
@@ -31,8 +31,10 @@ pub enum ComposeError {
|
||||
UnknownView,
|
||||
/// A label or a path of the layer holds a code point XML 1.0 cannot carry.
|
||||
InvalidCharacter,
|
||||
/// A reference of the drawing kept outside its view's scope after scoping (fail-closed:
|
||||
/// the reader keeps no such reference, so this never happens on a read drawing).
|
||||
/// A reference of the drawing kept outside its view's scope after scoping, or a `url(` the
|
||||
/// scoping does not read. Fail-closed: the reader keeps no attribute with a `url(` it does
|
||||
/// not read as a local reference (`sanitize::value_acceptable`), so only an element tree
|
||||
/// that did not come out of `read_svg` reaches it.
|
||||
UnscopedReference,
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ const ALLOWED_ELEMENTS: [&str; 28] = [
|
||||
"use",
|
||||
];
|
||||
|
||||
const ALLOWED_ATTRIBUTES: [&str; 74] = [
|
||||
const ALLOWED_ATTRIBUTES: [&str; 77] = [
|
||||
"id",
|
||||
"class",
|
||||
"d",
|
||||
@@ -110,6 +110,9 @@ const ALLOWED_ATTRIBUTES: [&str; 74] = [
|
||||
"color-interpolation-filters",
|
||||
"filterUnits",
|
||||
"primitiveUnits",
|
||||
"maskUnits",
|
||||
"maskContentUnits",
|
||||
"clipPathUnits",
|
||||
"systemLanguage",
|
||||
"font-family",
|
||||
"font-size",
|
||||
@@ -415,12 +418,16 @@ fn is_xml_space(text: &str) -> bool {
|
||||
|
||||
/// The engine's value rules, in its order, then the R3 id grammar.
|
||||
fn value_acceptable(qname: &str, value: &str) -> bool {
|
||||
if value.contains('\\') || !urls_are_local(value) {
|
||||
if value.contains('\\') || !urls_are_local(value) || !urls_unglued(value) {
|
||||
return false;
|
||||
}
|
||||
match qname {
|
||||
"href" | "xlink:href" => is_local_reference(local_reference_text(value)),
|
||||
"id" => is_reference_name(value),
|
||||
// Figma writes `maskUnits="userSpaceOnUse"` (owner decision 2026-10-30): the keywords only.
|
||||
"maskUnits" | "maskContentUnits" | "clipPathUnits" => {
|
||||
matches!(value, "userSpaceOnUse" | "objectBoundingBox")
|
||||
}
|
||||
"style" => !style_forbidden(value) && calls_only_local_url(value),
|
||||
_ if PRESENTATION_ATTRIBUTES.contains(&qname) => calls_only_local_url(value),
|
||||
_ => true,
|
||||
@@ -542,6 +549,13 @@ pub fn urls_are_local(value: &str) -> bool {
|
||||
url_openings(value).all(|at| local_url_target(value, at).is_some())
|
||||
}
|
||||
|
||||
/// Every case-insensitive `url(` of the value is one `url_openings` reads: no attribute keeps a
|
||||
/// `url(` glued to a longer name (`xurl(#a)`, final review 2026-10-30), so a kept value holds
|
||||
/// as many `url(` as references, the count the composer checks.
|
||||
fn urls_unglued(value: &str) -> bool {
|
||||
value.to_ascii_lowercase().matches("url(").count() == url_openings(value).count()
|
||||
}
|
||||
|
||||
/// No `(` once the `url(#` openings and the strict colour functions are taken out.
|
||||
fn calls_only_local_url(value: &str) -> bool {
|
||||
let mut cut = String::with_capacity(value.len());
|
||||
|
||||
Reference in new issue
Block a user