DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge storytold/main into PR #1893
Brandon Thomas7c24b673af00
diff --cc crates/engine/src/cmd/xml.rsindex 8905c2368,73144d1f6..f3d55099b--- a/crates/engine/src/cmd/xml.rs+++ b/crates/engine/src/cmd/xml.rs@@@ -480,19 -488,18 +493,31 @@@ mod testsassert!(s.execute("xml.validate", &json!({})).is_err());}+ #[test]+ fn export_xml_drops_forbidden_control_chars() {+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ let a = s+ .execute("frame.create", &json!({"rect": [72, 72, 400, 150], "content": "text", "text": "A\u{1}B\u{8}C\u{FFFE}\u{FFFF}", "caret": false}))+ .unwrap();+ s.execute("xml.tag", &json!({"tag": "story", "ids": [a["id"]]})).unwrap();+ let x = s.execute("file.exportXml", &json!({})).unwrap()["text"].as_str().unwrap().to_string();+ assert!(x.contains("<story>ABC</story>"), "{x:?}");+ }++ #[test]+ fn map_style_rejects_invalid_tag_name() {+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "Head"})).unwrap();+ assert!(s.execute("xml.mapStyle", &json!({"style": "Head", "tag": "a b><x"})).is_err());+ let d = &s.doc().unwrap().doc;+ assert!(d.xml.style_map.is_empty());+ assert!(d.xml.tags.iter().all(|t| t.name != "a b><x"));+ s.execute("xml.mapStyle", &json!({"style": "Head", "tag": "title"})).unwrap();+ assert_eq!(s.doc().unwrap().doc.xml.style_map.len(), 1);+ }+#[test]fn tag_export_and_import_xml() {let mut s = Session::new();