fix(anatomy): R5.4 Markdown guard from a TypeScript sweep, strict drawing comparison, unwritable characters refused, indexed renderers
This commit is contained in:
1 parent
0a79c52e62
commit
94f8b35105
14 files changed
+647
-50
No files matched your search
@@ -204,6 +204,42 @@ fn an_undeclared_drawing_difference_is_refused() {
|
||||
assert!(compare_drawing(&moved, &app, Some(&rule)).is_err());
|
||||
}
|
||||
|
||||
/// The tree fallback hides nothing (final gate R5.4): a stylesheet processing instruction, a
|
||||
/// comment or another declared encoding in the committed application drawing is refused,
|
||||
/// although the trees would still be equal under the rule.
|
||||
#[test]
|
||||
fn the_rule_fallback_refuses_what_the_tree_does_not_carry() {
|
||||
let (result, draft) = equine();
|
||||
let files = render_draft_artifacts(&draft, &result.anomalies).unwrap();
|
||||
let produced = &files
|
||||
.iter()
|
||||
.find(|(file, _)| file == "review/app-main.svg")
|
||||
.unwrap()
|
||||
.1;
|
||||
let committed = common::repo_file(&format!("{DRAFT}/review/app-main.svg"));
|
||||
let rule = TriggerNames::of(&typed(&draft.document));
|
||||
assert_eq!(
|
||||
compare_drawing(produced, &committed, Some(&rule)),
|
||||
Ok(Match::TreeAfterRule)
|
||||
);
|
||||
let stylesheet = committed.replacen(
|
||||
"?>\n",
|
||||
"?>\n<?xml-stylesheet type=\"text/css\" href=\"https://attacker.invalid/x.css\"?>\n",
|
||||
1,
|
||||
);
|
||||
let comment = committed.replacen("</svg>", "<!-- hidden --></svg>", 1);
|
||||
let trailing = format!("{committed}<!-- after -->");
|
||||
let encoding = committed.replacen("encoding=\"UTF-8\"", "encoding=\"ISO-8859-1\"", 1);
|
||||
for variant in [stylesheet, comment, trailing, encoding] {
|
||||
assert_ne!(variant, committed);
|
||||
assert!(compare_drawing(produced, &variant, Some(&rule)).is_err());
|
||||
}
|
||||
// A difference the rule does not touch, on a file the rule could apply to.
|
||||
let head = common::repo_file(&format!("{DRAFT}/review/app-head.svg"));
|
||||
let commented = head.replacen("</svg>", "<!-- x --></svg>", 1);
|
||||
assert!(compare_drawing(&head, &commented, Some(&rule)).is_err());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Synthetic cases written by the TypeScript (`oracles/r5/review-synthetic.json`).
|
||||
|
||||
@@ -358,3 +394,30 @@ fn case_document(frozen: &Value, case: &Value) -> Value {
|
||||
.unwrap()
|
||||
.document
|
||||
}
|
||||
|
||||
/// A label XML cannot carry, or a carriage return xmldom wrote raw and the core escapes, never
|
||||
/// reaches a review drawing (final gate R5.4): the drawing is refused.
|
||||
#[test]
|
||||
fn a_label_the_drawing_cannot_carry_is_refused() {
|
||||
let frozen = oracle("review-synthetic.json");
|
||||
let references = parse_references(
|
||||
&to_js_compact(&serde_json::json!({ "references": frozen["references"] })).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let drawing = read_cleaned_drawing(frozen["drawing"].as_str().unwrap().as_bytes()).unwrap();
|
||||
for label in ["Hanche\u{1}", "Han\rche"] {
|
||||
let file = serde_json::json!({ "changes": [{
|
||||
"id": "CHG-001", "level": "A", "kind": "technical",
|
||||
"title": { "fr": "Essai", "en": "Test" }, "rationale": "Essai", "reference_ids": [],
|
||||
"ops": [{ "op": "set", "target": "annotation:hip", "field": "name.fr", "value": label }],
|
||||
}]});
|
||||
let changeset = parse_changeset(&to_js_compact(&file).unwrap()).unwrap();
|
||||
let result = apply_changeset(&frozen["baseline"], &references, &changeset.changes).unwrap();
|
||||
let error =
|
||||
render_app_review_drawing(&drawing, &typed(&result.document), "main").unwrap_err();
|
||||
assert!(
|
||||
error.to_string().contains("cannot carry"),
|
||||
"{label:?}: {error}"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user