Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

SVG import: no slice indexing when writing a new style attribute

Gert Pellin6f9595542d35
diff --git a/crates/svg/src/import.rs b/crates/svg/src/import.rs
index 231963e30..323621e1f 100644
--- a/crates/svg/src/import.rs
+++ b/crates/svg/src/import.rs
@@ -524,7 +524,7 @@ impl Edits {
/// skipped.
fn apply(mut self, svg: &str) -> Cow<'_, str> {
for (at, has_style, decls) in std::mem::take(&mut self.styles).into_values() {
- self.insert(at, if has_style { decls } else { format!(" style=\"{}\"", &decls[1..]) });
+ self.insert(at, if has_style { decls } else { format!(" style=\"{}\"", decls.strip_prefix(';').unwrap_or(&decls)) });
}
if self.list.is_empty() {
return svg.into();