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());
|
||||
|
||||
+20
-2
@@ -30,5 +30,23 @@ covered above by a real 1.4.3 export). The owner opens `inkscape-source.svg` in
|
||||
exports it unchanged and puts the files in `owner/`, named `<tool>-<version>-<date>-<variant>.svg`;
|
||||
`owner/README.md` gives the exact steps. The suite reads every file there: each must be refused
|
||||
(with a closed reason) or cleaned into a stored form that reads back with no removal, and a file
|
||||
whose name contains `-active-` must be refused for active content. Until files arrive, that test
|
||||
runs on an empty folder and A6 stays open.
|
||||
whose name contains `-active-` must be refused for active content. A6 (owner, 2026-10-30)
|
||||
requires Figma and the real Adobe Illustrator; Affinity is optional. Status: Figma committed
|
||||
and passing, Illustrator awaited, so A6 stays open.
|
||||
|
||||
| File | Tool | Expected |
|
||||
|---|---|---|
|
||||
| `owner/figma-web-20261030-default.svg` | Figma in the browser (no version shown), exported by the owner on 2026-10-30, raw | clean, nothing removed |
|
||||
| `owner/figma-web-20261030-ids.svg` | same, « Include "id" attribute » | cleanable: `g@id` (layer names with spaces, `Clip path group`, outside the id grammar; nothing names them) |
|
||||
|
||||
What Figma writes, as read in these two files: the drawing is the 180 × 130 frame Figma made
|
||||
from the source's clip rectangle (coordinates shifted by 10); the clip path becomes a
|
||||
`<mask style="mask-type:luminance" maskUnits="userSpaceOnUse">` holding a white rectangle,
|
||||
applied by `mask="url(#mask0_3_9)"`; the dashed stroke is expanded into one path of dash
|
||||
segments (no `stroke-dasharray`); the ellipse and the rounded rectangle are paths;
|
||||
`fill="none"` sits on the root; the gradient is in a `defs` written after its use,
|
||||
`gradientUnits="userSpaceOnUse"`, colours in uppercase hex. Neither file carries the live
|
||||
text « Garrot », as text or as outlines, so Figma's handling of text is not covered by these
|
||||
fixtures. Kept by the owner's decision of 2026-10-30: `maskUnits` (removing it re-read the
|
||||
mask region in bounding-box units and cut half a stroke at (10, 100) in Chromium 156); the
|
||||
stored forms render pixel-identical to the raw files (Chromium 156, × 8).
|
||||
+7
-1
@@ -17,6 +17,9 @@ differently, and I could not check them here.
|
||||
|
||||
## Illustrator (Fichier › Ouvrir… `inkscape-source.svg`)
|
||||
|
||||
Required for A6 (owner, 2026-10-30), and only from the real Adobe Illustrator:
|
||||
VectorCraft or another look-alike is not equivalent.
|
||||
|
||||
1. File › Export › Export As… › format SVG, « Use Artboards » ticked.
|
||||
2. SVG Options, two exports of the same drawing:
|
||||
- `…-presentation.svg`: Styling « Presentation Attributes », Font « SVG »
|
||||
@@ -30,13 +33,16 @@ differently, and I could not check them here.
|
||||
|
||||
## Figma (import `inkscape-source.svg` into a file, or drag it onto the canvas)
|
||||
|
||||
Done on 2026-10-30: `figma-web-20261030-default.svg` and `figma-web-20261030-ids.svg`
|
||||
(the date written without dashes), committed raw; see `../README.md`.
|
||||
|
||||
1. Select the imported frame, right panel › Export › « + » › SVG.
|
||||
2. Two exports:
|
||||
- `…-default.svg`: the defaults;
|
||||
- `…-ids.svg`: « Include "id" attribute » ticked, « Outline text » unticked
|
||||
(text kept as text).
|
||||
|
||||
## Affinity (Designer 2 or Affinity, if you use it; otherwise say so and A6 drops it)
|
||||
## Affinity (optional since the owner's decision of 2026-10-30)
|
||||
|
||||
File › Open `inkscape-source.svg`, then File › Export › SVG, preset « SVG (for
|
||||
web) » (`…-web.svg`); if offered, a second with « SVG (digital – high quality) »
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<svg width="180" height="130" viewBox="0 0 180 130" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="mask0_3_9" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="180" height="130">
|
||||
<path d="M180 0H0V130H180V0Z" fill="white"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_3_9)">
|
||||
<path d="M10 100C30 30 140 20 170 90L160 110L20 115L10 100Z" fill="url(#paint0_linear_3_9)"/>
|
||||
<path d="M11.6667 102.5L10 100C10.2753 99.0363 10.5677 98.0841 10.8767 97.1432M13.3333 105L16.6667 110M18.3333 112.5L20 115L22.9167 114.896M25.8333 114.792L31.6667 114.583M34.5833 114.479L40.4167 114.271M43.3333 114.167L49.1667 113.958M52.0833 113.854L57.9167 113.646M60.8333 113.542L66.6667 113.333M69.5833 113.229L75.4167 113.021M78.3333 112.917L84.1667 112.708M87.0833 112.604L92.9167 112.396M95.8333 112.292L101.667 112.083M104.583 111.979L110.417 111.771M113.333 111.667L119.167 111.458M122.083 111.354L127.917 111.146M130.833 111.042L136.667 110.833M139.583 110.729L145.417 110.521M148.333 110.417L154.167 110.208M157.083 110.104L160 110L161.667 106.667M163.333 103.333L166.667 96.6667M168.333 93.3333L170 90C169.604 89.076 169.194 88.1659 168.771 87.2697M167.46 84.6227C166.537 82.8434 165.56 81.1223 164.53 79.4589M162.926 76.9743C161.811 75.3196 160.643 73.7261 159.425 72.1932M157.527 69.8984C156.227 68.3901 154.878 66.9454 153.482 65.5638M151.337 63.5225C149.871 62.1816 148.359 60.9058 146.805 59.6946M144.431 57.9168C142.821 56.7597 141.172 55.6682 139.486 54.6418M136.924 53.1463C135.196 52.181 133.435 51.281 131.643 50.4458M128.933 49.2409C127.112 48.47 125.264 47.7638 123.392 47.1217M120.571 46.2076C118.681 45.6306 116.77 45.1171 114.843 44.6668M111.942 44.0391C110.004 43.6528 108.052 43.329 106.09 43.0671M103.144 42.7213C101.178 42.5217 99.2039 42.3836 97.2261 42.3064M94.2604 42.2364C92.2833 42.22 90.3048 42.2641 88.3291 42.3682M85.369 42.5693C83.3979 42.7332 81.4317 42.9568 79.4746 43.2396M76.5448 43.7084C74.5956 44.0507 72.6577 44.4521 70.7353 44.9122M67.8622 45.6465C65.9518 46.1663 64.0592 46.7447 62.1887 47.3812M59.3947 48.3815C57.5413 49.0784 55.7122 49.8335 53.9119 50.6464M51.2288 51.9113C49.4519 52.785 47.7061 53.7166 45.9958 54.7056M43.454 56.2342C41.7759 57.2832 40.1357 58.3897 38.5377 59.5531M36.1712 61.3421C34.6161 62.5627 33.1056 63.8399 31.6439 65.1734M29.4896 67.2146C28.0825 68.5995 26.7261 70.04 25.4249 71.5355M23.5252 73.8073C22.2918 75.3427 21.1147 76.9318 19.9981 78.5741M18.3778 81.0635C17.3398 82.7305 16.3625 84.4488 15.4497 86.2179M14.1435 88.8796C13.3152 90.6566 12.5505 92.4819 11.8531 94.3549" stroke-width="2" stroke="#333333"/>
|
||||
<path d="M150 57C159.941 57 168 51.6274 168 45C168 38.3726 159.941 33 150 33C140.059 33 132 38.3726 132 45C132 51.6274 140.059 57 150 57Z" fill="#C49A6C"/>
|
||||
<path d="M86 50H54C51.7909 50 50 51.7909 50 54V66C50 68.2091 51.7909 70 54 70H86C88.2091 70 90 68.2091 90 66V54C90 51.7909 88.2091 50 86 50Z" fill="#3366B3" fill-opacity="0.5"/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_3_9" x1="10" y1="42.233" x2="170" y2="42.233" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#8A5A3C"/>
|
||||
<stop offset="1" stop-color="#D9B48F" stop-opacity="0.8"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1,25 @@
|
||||
<svg width="180" height="130" viewBox="0 0 180 130" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="Clip path group">
|
||||
<mask id="mask0_3_9" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="180" height="130">
|
||||
<g id="frame">
|
||||
<path id="Vector" d="M180 0H0V130H180V0Z" fill="white"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_3_9)">
|
||||
<g id="body">
|
||||
<g id="Vector_2">
|
||||
<path d="M10 100C30 30 140 20 170 90L160 110L20 115L10 100Z" fill="url(#paint0_linear_3_9)"/>
|
||||
<path d="M11.6667 102.5L10 100C10.2753 99.0363 10.5677 98.0841 10.8767 97.1432M13.3333 105L16.6667 110M18.3333 112.5L20 115L22.9167 114.896M25.8333 114.792L31.6667 114.583M34.5833 114.479L40.4167 114.271M43.3333 114.167L49.1667 113.958M52.0833 113.854L57.9167 113.646M60.8333 113.542L66.6667 113.333M69.5833 113.229L75.4167 113.021M78.3333 112.917L84.1667 112.708M87.0833 112.604L92.9167 112.396M95.8333 112.292L101.667 112.083M104.583 111.979L110.417 111.771M113.333 111.667L119.167 111.458M122.083 111.354L127.917 111.146M130.833 111.042L136.667 110.833M139.583 110.729L145.417 110.521M148.333 110.417L154.167 110.208M157.083 110.104L160 110L161.667 106.667M163.333 103.333L166.667 96.6667M168.333 93.3333L170 90C169.604 89.076 169.194 88.1659 168.771 87.2697M167.46 84.6227C166.537 82.8434 165.56 81.1223 164.53 79.4589M162.926 76.9743C161.811 75.3196 160.643 73.7261 159.425 72.1932M157.527 69.8984C156.227 68.3901 154.878 66.9454 153.482 65.5638M151.337 63.5225C149.871 62.1816 148.359 60.9058 146.805 59.6946M144.431 57.9168C142.821 56.7597 141.172 55.6682 139.486 54.6418M136.924 53.1463C135.196 52.181 133.435 51.281 131.643 50.4458M128.933 49.2409C127.112 48.47 125.264 47.7638 123.392 47.1217M120.571 46.2076C118.681 45.6306 116.77 45.1171 114.843 44.6668M111.942 44.0391C110.004 43.6528 108.052 43.329 106.09 43.0671M103.144 42.7213C101.178 42.5217 99.2039 42.3836 97.2261 42.3064M94.2604 42.2364C92.2833 42.22 90.3048 42.2641 88.3291 42.3682M85.369 42.5693C83.3979 42.7332 81.4317 42.9568 79.4746 43.2396M76.5448 43.7084C74.5956 44.0507 72.6577 44.4521 70.7353 44.9122M67.8622 45.6465C65.9518 46.1663 64.0592 46.7447 62.1887 47.3812M59.3947 48.3815C57.5413 49.0784 55.7122 49.8335 53.9119 50.6464M51.2288 51.9113C49.4519 52.785 47.7061 53.7166 45.9958 54.7056M43.454 56.2342C41.7759 57.2832 40.1357 58.3897 38.5377 59.5531M36.1712 61.3421C34.6161 62.5627 33.1056 63.8399 31.6439 65.1734M29.4896 67.2146C28.0825 68.5995 26.7261 70.04 25.4249 71.5355M23.5252 73.8073C22.2918 75.3427 21.1147 76.9318 19.9981 78.5741M18.3778 81.0635C17.3398 82.7305 16.3625 84.4488 15.4497 86.2179M14.1435 88.8796C13.3152 90.6566 12.5505 92.4819 11.8531 94.3549" stroke-width="2" stroke="#333333"/>
|
||||
</g>
|
||||
<path id="Vector_3" d="M150 57C159.941 57 168 51.6274 168 45C168 38.3726 159.941 33 150 33C140.059 33 132 38.3726 132 45C132 51.6274 140.059 57 150 57Z" fill="#C49A6C"/>
|
||||
<path id="Vector_4" d="M86 50H54C51.7909 50 50 51.7909 50 54V66C50 68.2091 51.7909 70 54 70H86C88.2091 70 90 68.2091 90 66V54C90 51.7909 88.2091 50 86 50Z" fill="#3366B3" fill-opacity="0.5"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_3_9" x1="10" y1="42.233" x2="170" y2="42.233" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#8A5A3C"/>
|
||||
<stop offset="1" stop-color="#D9B48F" stop-opacity="0.8"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
@@ -413,6 +413,126 @@ fn every_url_spelling_but_the_strict_one_is_refused() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Final review 2026-10-30: the one `url(` grammar holds in every attribute, not only in the
|
||||
/// presentation ones. A `url(` glued to a longer name, however spelt, is removed wherever it
|
||||
/// stands; a non-strict `url(` is active content; a reference to an absent id is refused; a
|
||||
/// strict reference and a value with no `url(` are kept.
|
||||
#[test]
|
||||
fn every_attribute_reads_url_with_the_one_grammar() {
|
||||
let svg = |attr: &str, value: &str| {
|
||||
format!(
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 10 10\">\
|
||||
<linearGradient id=\"a\"/><g {attr}=\"{value}\"><path d=\"M0 0\"/></g></svg>"
|
||||
)
|
||||
};
|
||||
for attr in ["class", "result", "values", "transform", "in", "type"] {
|
||||
for value in [
|
||||
"xurl(#a)",
|
||||
"-url(#a)",
|
||||
"_url(#a)",
|
||||
"9url(#a)",
|
||||
"éurl(#a)",
|
||||
"\u{a0}url(#a)",
|
||||
"xurl(#a)",
|
||||
"xURL(#a)",
|
||||
"url(#a) xurl(#a)",
|
||||
] {
|
||||
let cleaning = clean_svg(svg(attr, value).as_bytes());
|
||||
assert_eq!(outcome(&cleaning), (Cleanable, None), "{attr}={value}");
|
||||
assert_eq!(cleaning.removed, [format!("g@{attr}")], "{attr}={value}");
|
||||
assert_fixpoint(cleaning.stored.as_deref().unwrap());
|
||||
}
|
||||
for value in [
|
||||
"url(#%61)",
|
||||
"url('#\ta')",
|
||||
"url(#a",
|
||||
"\\75rl(#a)",
|
||||
"u\\72l(#a)",
|
||||
] {
|
||||
let cleaning = clean_svg(svg(attr, value).as_bytes());
|
||||
assert_eq!(
|
||||
outcome(&cleaning),
|
||||
(Rejected, Some("svg_active_content")),
|
||||
"{attr}={value}"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
outcome(&clean_svg(svg(attr, "url(#nope)").as_bytes())),
|
||||
(Rejected, Some("dangling_reference")),
|
||||
"{attr}"
|
||||
);
|
||||
for value in ["url(#a)", "URL( '#a' )", "curl", "url", "a(b)", "M0 0"] {
|
||||
assert_eq!(
|
||||
outcome(&clean_svg(svg(attr, value).as_bytes())),
|
||||
(Clean, None),
|
||||
"{attr}={value}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Owner decision 2026-10-30 (Figma writes `maskUnits="userSpaceOnUse"`): the three unit
|
||||
/// attributes of masks and clip paths are kept with their two keywords only.
|
||||
#[test]
|
||||
fn mask_and_clip_units_keep_their_keywords_only() {
|
||||
for attr in ["maskUnits", "maskContentUnits", "clipPathUnits"] {
|
||||
for value in ["userSpaceOnUse", "objectBoundingBox"] {
|
||||
let svg = format!(
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\"><mask id=\"m\" {attr}=\"{value}\"/></svg>"
|
||||
);
|
||||
assert_eq!(
|
||||
outcome(&clean_svg(svg.as_bytes())),
|
||||
(Clean, None),
|
||||
"{attr}={value}"
|
||||
);
|
||||
}
|
||||
for value in ["", " userSpaceOnUse", "userspaceonuse", "url(#m)", "x(1)"] {
|
||||
let svg = format!(
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\"><mask id=\"m\" {attr}=\"{value}\"/></svg>"
|
||||
);
|
||||
let cleaning = clean_svg(svg.as_bytes());
|
||||
assert_eq!(cleaning.outcome, Cleanable, "{attr}={value}");
|
||||
assert_eq!(cleaning.removed, [format!("mask@{attr}")], "{attr}={value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The owner's Figma exports (2026-10-30, the frame of `inkscape-source.svg`, raw files): the
|
||||
/// clip path written as a luminance `mask` in user space, the dashed stroke expanded into path
|
||||
/// segments, the ellipse and the rectangle as paths, `fill="none"` on the root, the gradient
|
||||
/// after its use in `defs`. `ids` adds layer names as ids, some with spaces (`Clip path group`),
|
||||
/// which the id grammar removes; nothing names them. The live text is in neither file.
|
||||
#[test]
|
||||
fn the_figma_exports_keep_their_mask_gradient_and_shapes() {
|
||||
let cases: [(&str, CleaningOutcome, &[&str]); 2] = [
|
||||
("figma-web-20261030-default.svg", Clean, &[]),
|
||||
("figma-web-20261030-ids.svg", Cleanable, &["g@id"]),
|
||||
];
|
||||
for (file, expected, removed) in cases {
|
||||
let cleaning = clean_svg(&fixture(&format!("exports/owner/{file}")));
|
||||
assert_eq!(outcome(&cleaning), (expected, None), "{file}");
|
||||
assert_eq!(cleaning.removed, removed, "{file}");
|
||||
assert!(
|
||||
cleaning.active.is_empty() && !cleaning.style_removed,
|
||||
"{file}"
|
||||
);
|
||||
let stored = cleaning.stored.as_deref().unwrap();
|
||||
for kept in [
|
||||
"maskUnits=\"userSpaceOnUse\"",
|
||||
"style=\"mask-type:luminance\"",
|
||||
"mask=\"url(#mask0_3_9)\"",
|
||||
"fill=\"url(#paint0_linear_3_9)\"",
|
||||
"gradientUnits=\"userSpaceOnUse\"",
|
||||
"stop-opacity=\"0.8\"",
|
||||
"fill-opacity=\"0.5\"",
|
||||
] {
|
||||
assert!(stored.contains(kept), "{file}: {kept}");
|
||||
}
|
||||
assert!(!stored.contains("<text"), "{file}");
|
||||
assert_fixpoint(stored);
|
||||
}
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
//! reference keeps working; the composition is deterministic.
|
||||
#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use faunosteo_core::anatomy::compose::{ComposeError, compose_canvas, compose_highlight};
|
||||
use faunosteo_core::anatomy::svg::clean::{CleaningOutcome, clean_svg};
|
||||
use faunosteo_core::anatomy::svg::sanitize::{local_reference_text, url_targets};
|
||||
use faunosteo_core::anatomy::svg::tree::parse_svg;
|
||||
use faunosteo_core::anatomy::svg::{Element, SvgRejection, read_svg};
|
||||
use faunosteo_core::domain::sheet::AnatomicalSheetDocument;
|
||||
use faunosteo_core::domain::sheet::preview::{
|
||||
PreviewDrawing, PreviewDrawingStatus, PreviewInput, PreviewSheet, PreviewStatus,
|
||||
};
|
||||
@@ -342,3 +344,52 @@ fn every_reference_a_browser_reads_stays_in_its_view() {
|
||||
assert_eq!(refused["kind"], json!("svg_rejected"), "{value}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Final review 2026-10-30: a `url(` glued to a longer name (`xurl(#g)`, or after a no-break
|
||||
/// space) is no reference, and the reader removes it from any attribute, so every drawing the
|
||||
/// reader keeps composes alike into the canvas, the preview and the PDF view; before, the reader
|
||||
/// kept it in `class` or `result`, the verdict passed and only the canvas refused.
|
||||
#[test]
|
||||
fn the_canvas_the_preview_and_the_pdf_draw_every_drawing_the_reader_keeps() {
|
||||
let document: AnatomicalSheetDocument = serde_json::from_str(&document()).unwrap();
|
||||
for (attr, value) in [
|
||||
("class", "xurl(#g)"),
|
||||
("class", "-url(#g)"),
|
||||
("result", "aurl(#g)"),
|
||||
("values", "_url(#g)"),
|
||||
("transform", "\u{a0}url(#g)"),
|
||||
("class", "xurl(#g)"),
|
||||
] {
|
||||
let text = format!(
|
||||
"{OPEN}<radialGradient id=\"g\"/><g {attr}=\"{value}\"><path fill=\"url(#g)\" \
|
||||
d=\"M0 0\"/></g></svg>"
|
||||
);
|
||||
let read = read_svg(&text).unwrap();
|
||||
assert_eq!(read.removed, [format!("g@{attr}")], "{value}");
|
||||
let cleaning = clean_svg(text.as_bytes());
|
||||
assert_eq!(cleaning.outcome, CleaningOutcome::Cleanable, "{value}");
|
||||
compose_canvas(&document, "detail", &read.root).unwrap();
|
||||
compose_highlight(&document, "detail", read.root, &HashSet::new(), false).unwrap();
|
||||
canvas(&preview(cleaning.stored.as_deref().unwrap()), "detail");
|
||||
}
|
||||
}
|
||||
|
||||
/// The composer stays fail-closed on a tree that did not come out of the reader: a glued
|
||||
/// `url(` or a reference leaving the document is never inlined in the page.
|
||||
#[test]
|
||||
fn the_composer_refuses_a_reference_it_does_not_scope() {
|
||||
let document: AnatomicalSheetDocument = serde_json::from_str(&document()).unwrap();
|
||||
for (attr, value) in [
|
||||
("class", "xurl(#g)"),
|
||||
("fill", "url(#%67)"),
|
||||
("href", "https://example.org/a.svg#g"),
|
||||
] {
|
||||
let mut root = read_svg(&detail_drawing()).unwrap().root;
|
||||
root.set_attr(attr, value.to_owned());
|
||||
assert_eq!(
|
||||
compose_canvas(&document, "detail", &root).unwrap_err(),
|
||||
ComposeError::UnscopedReference,
|
||||
"{attr}={value}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,9 @@ keep a reference outside its scope. A drawing whose reference names an id it
|
||||
does not define is refused by the reader (`dangling_reference`); a `url(` spelt
|
||||
any other way than `url(#id)` with optional quotes and spaces is removed by the
|
||||
reader, so the cleaning refuses the file as active content and the verdict as a
|
||||
removal. The annotation
|
||||
removal. A `url(` glued to a longer name (`xurl(#a)`) is no reference: the reader
|
||||
removes the attribute holding it, whatever the attribute (2026-10-30), so every
|
||||
drawing the reader keeps composes into the canvas and the PDF view alike. The annotation
|
||||
layer carries no `id`. The PDF view keeps the drawing's ids: it is rasterised
|
||||
as a document of its own. The R3 canvas goldens stay frozen; the tests apply
|
||||
this declared change to them (`withIdsScopedPerView`,
|
||||
|
||||
@@ -3950,7 +3950,7 @@ trapping test stub (`apps/app/tests/helpers/core.ts`) lists the two new glue mem
|
||||
|
||||
| Measure | Value |
|
||||
|---|---|
|
||||
| shipped module | 1 512 413 B raw, 558 859 B gzip -9 (script), 568 696 B by Node's gzip in `size.test.ts` (final, f1ef6a4: the debug `name` section dropped, §12.7); budget 600 000 (D-R13); 596 671 B at ca31b78, 531 715 B before V1-2.2 (RUST.md §11.22) |
|
||||
| shipped module | 1 513 522 B raw, 559 360 B gzip -9 (script), 569 181 B by Node's gzip in `size.test.ts` (final, finalisation §12.8; 568 696 B at f1ef6a4, the debug `name` section dropped since §12.7); budget 600 000 (D-R13); 596 671 B at ca31b78, 531 715 B before V1-2.2 (RUST.md §11.22) |
|
||||
| verdict at every cap, native | 107 ms release, 493 ms debug (document 1 165 850 bytes) |
|
||||
| `clean_svg`, shipped module | 45 hostile inputs and floods, slowest 0.4 ms |
|
||||
|
||||
@@ -3969,11 +3969,12 @@ with a PI shown `rejected` by the preview as the verdict refuses it.
|
||||
|
||||
### 12.6 Residual risks and points for V1-2.3
|
||||
|
||||
- The module's margin under its budget is about 31.3 KB by the test's measure since §12.7 (3.3 KB before): the V1-2.5 and V1-2.6 pages must not grow the
|
||||
- The module's margin under its budget is about 30.8 KB by the test's measure since §12.8 (31.3 KB at §12.7) (3.3 KB before): the V1-2.5 and V1-2.6 pages must not grow the
|
||||
core's browser surface without measuring.
|
||||
- cairo colours: closed at the checkpoint (§12.7), strict numeric `rgb()` / `rgba()` kept.
|
||||
- Editor exports: Inkscape 1.4.3 covered at the checkpoint (§12.7); Illustrator, Figma and Affinity pending from the
|
||||
owner, their real output untested until then (A6 open).
|
||||
- Editor exports: Inkscape 1.4.3 covered at the checkpoint (§12.7), Figma at the finalisation (§12.8); the real Adobe
|
||||
Illustrator pending from the owner, its output untested until then (A6 open); Affinity optional. Figma's text
|
||||
handling is untested: neither owner file carries the source's live text.
|
||||
- A verdict whose document does not read strictly carries no group and no drawing: M6's structure check
|
||||
(`complete_sheet_verification`) must accept a failed verdict without them, or the round would wait for its attempt limit.
|
||||
- `PreviewSheet` handles are not yet under `CoreRuntime`'s poison and recovery (§8.3): the first page that holds one adds
|
||||
@@ -4049,3 +4050,22 @@ gzip, but `is_url` must keep matching `new URL()`), the PDF writer, reader and i
|
||||
(about 55 to 60 KB gzip by the attribution above, estimated; the editor pages never export), `wasm-opt -Oz` in the build
|
||||
(not installed here; to be measured). No security check, validation or feature is removed for size.
|
||||
|
||||
|
||||
### 12.8 Finalisation (owner, 2026-10-30)
|
||||
|
||||
Brief « V1-2.2 : finalisation et intégration A6 Figma » on `98060d7`, after the final independent review of `05de816`
|
||||
(verifier ECARTS(3): A6 open, a LOW in `f1ef6a4`, a floor false positive; security PASS). Decisions in contract §17.5.
|
||||
|
||||
| Point | Built | Where |
|
||||
|---|---|---|
|
||||
| Glued `url(` | `sanitize::urls_unglued`: a value keeps every case-insensitive `url(` only when `url_openings` reads each one, so no attribute keeps `xurl(#a)` (or `url(` after a no-break space); before, `class`, `result`, `values` kept it, the verdict passed and only the canvas refused it (`unscoped_reference`) while the PDF drew it. Same helper as the reader, no second parser; the composer's count now holds on every read drawing | `anatomy/svg/sanitize.rs`, `anatomy/compose.rs` (comment) |
|
||||
| Mask and clip units | `maskUnits`, `maskContentUnits`, `clipPathUnits` allowed, values `userSpaceOnUse` / `objectBoundingBox` only | `anatomy/svg/sanitize.rs` |
|
||||
| Figma | the owner's two raw exports committed under `fixtures/svg/exports/owner/`: `default` clean, `ids` cleanable (`g@id`); stored forms pixel-identical to the raw files in Chromium 156 (208 pixels at × 8 differed before the units were allowed) | `tests/svg_clean.rs`, exports README |
|
||||
|
||||
Tests: `svg_clean` (`every_attribute_reads_url_with_the_one_grammar`: six attributes × nine glued spellings removed,
|
||||
five non-strict or escaped spellings refused, an absent target refused, six values kept;
|
||||
`mask_and_clip_units_keep_their_keywords_only`; `the_figma_exports_keep_their_mask_gradient_and_shapes`); `svg_scope`
|
||||
(`the_canvas_the_preview_and_the_pdf_draw_every_drawing_the_reader_keeps`, `the_composer_refuses_a_reference_it_does_not_scope`,
|
||||
which reaches the fail-closed branch on a tree built outside the reader). Mutations: dropping `urls_unglued`, the
|
||||
keyword check or the `maskUnits` entry each fails the new tests. No frozen oracle, N-1 copy, protected reader or equine
|
||||
file changed.
|
||||
@@ -2385,6 +2385,17 @@ Asked before the code of V1-2.2, on the brief « Autorisation de démarrer V1-2.
|
||||
| Inkscape exports | the Ubuntu archive package of Inkscape 1.4.3 unpacked in the session scratch folder (no install) produces real exports, committed with their generator; Illustrator and Figma stay owner-supplied, A6 open until they arrive | §9.2, §15 |
|
||||
| Module size | the shipped module drops wasm-bindgen's debug `name` section (`--remove-name-section`); the 600 000-byte cap and its test are kept | RUST.md §12 |
|
||||
|
||||
### 17.5 V1-2.2 finalisation (owner, 2026-10-30)
|
||||
|
||||
Brief « V1-2.2 : finalisation et intégration A6 Figma », after the final independent review of `05de816`:
|
||||
|
||||
| Item | Decision | Where |
|
||||
|---|---|---|
|
||||
| Editor exports required for A6 | Inkscape (covered, §17.4), Figma (required: the owner's two raw exports `owner/figma-web-20261030-{default,ids}.svg`) and Illustrator (required: the real Adobe Illustrator; VectorCraft or any look-alike is not equivalent). Affinity is optional. A6 stays open until the Illustrator exports are committed and pass | §9.2, §15 |
|
||||
| Mask and clip units | `maskUnits`, `maskContentUnits` and `clipPathUnits` kept with the keywords `userSpaceOnUse` and `objectBoundingBox` only, any other value removed: removing Figma's `maskUnits="userSpaceOnUse"` re-read the mask region in bounding-box units and cut the drawing's edge | §9.2 |
|
||||
| Glued `url(` | a `url(` glued to a longer name (`xurl(#a)`) is removed from any attribute, not only from presentation attributes and `style`, so the reader, the cleaning, the verdict, the preview, the canvas and the PDF view accept the same drawings | §9.2, §10 |
|
||||
| Document instances | the per-document prefix (§10) stays a requirement before any page draws two documents at once | §10 |
|
||||
|
||||
---
|
||||
|
||||
## 18. Documents touched by V1-2.0
|
||||
|
||||
Reference in new issue
Block a user