fix(anatomy): V1-2.2 owner arbitrations on SVG references and bytes
Refuse local references to ids a drawing does not define, scope canvas ids per view, upload every drawing in one stored form checked by the verdict and the preview, keep strict numeric rgb() colours, and commit real Inkscape 1.4.3 exports with their generator.
This commit is contained in:
1 parent
17d919971e
commit
e823655f09
31 files changed
+1362
-110
No files matched your search
@@ -15,8 +15,11 @@ use faunosteo_core::domain::sheet::verdict::{
|
||||
use serde_json::{Value, json};
|
||||
|
||||
const ASSET: &str = "11111111-2222-4333-8444-555555555555";
|
||||
const DRAWING: &str =
|
||||
r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><path d="M0 0L5 5"/></svg>"#;
|
||||
/// A drawing in its stored form (`serialize::stored_form`), as the page's cleaning uploads it.
|
||||
const DRAWING: &str = concat!(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
|
||||
r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><path d="M0 0L5 5"/></svg>"#
|
||||
);
|
||||
const SEED: &str = "supabase/seed/anatomical-sheets/equine/draft";
|
||||
const HORSE_ID: &str = "7f767f74-3b36-51a7-8465-52dd7e2ead4a";
|
||||
|
||||
@@ -281,6 +284,43 @@ fn each_drawing_fault_fails_with_its_code() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Owner decision 2026-10-29: a stored drawing must be in the stored form the page's cleaning
|
||||
/// writes; bytes read with no removal but written otherwise (original export bytes, another
|
||||
/// declared encoding, an HTML-only comment form, another quoting) fail, never repaired.
|
||||
#[test]
|
||||
fn a_drawing_outside_the_stored_form_fails() {
|
||||
let doc = document();
|
||||
let body = DRAWING.split_once('\n').unwrap().1;
|
||||
let export = std::fs::read(common::repo_path(
|
||||
"crates/core/tests/fixtures/svg/exports/imagemagick-7.1.2-18-draw.svg",
|
||||
))
|
||||
.unwrap();
|
||||
let mut doc_on_export = doc.clone();
|
||||
doc_on_export["views"][0]["view_box"] = Value::Null;
|
||||
for bytes in [
|
||||
body.as_bytes().to_vec(),
|
||||
format!("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n{body}").into_bytes(),
|
||||
DRAWING.replace("<path", "<!-->--><path").into_bytes(),
|
||||
DRAWING
|
||||
.replace("viewBox=\"0 0 10 10\"", "viewBox='0 0 10 10'")
|
||||
.into_bytes(),
|
||||
format!("{DRAWING}\n").into_bytes(),
|
||||
export,
|
||||
] {
|
||||
let v = verdict_of(&doc, vec![row(&bytes)]);
|
||||
assert_eq!(
|
||||
failures(&v),
|
||||
[codes::SVG_NOT_CANONICAL],
|
||||
"{}",
|
||||
String::from_utf8_lossy(&bytes)
|
||||
);
|
||||
assert_eq!(v.drawings[0].result, DrawingResult::SvgNotCanonical);
|
||||
assert!(v.fingerprint.is_some());
|
||||
}
|
||||
let v = verdict_of(&doc, vec![row(DRAWING.as_bytes())]);
|
||||
assert_eq!(v.drawings[0].result, DrawingResult::Ok);
|
||||
}
|
||||
|
||||
/// `count` annotations drawn in the main view, all in zone `z1`.
|
||||
fn with_annotations(count: usize) -> Value {
|
||||
let mut doc = document();
|
||||
|
||||
Reference in new issue
Block a user