Skip to content

Commit

Permalink
Fix unescaped <dc:source> content in SVG output (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 authored Jan 14, 2024
1 parent b6ab2e1 commit 94f2e6a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/vsvg/src/svg/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub(crate) fn document_to_svg_doc<

if let Some(source) = document.metadata().source.as_ref() {
let mut dc_source = svg::node::element::Element::new("dc:source");
dc_source.append(svg::node::Text::new(source));
dc_source.append(svg::node::Text::new(quick_xml::escape::escape(source)));
cc.append(dc_source);
}
let mut rdf = svg::node::element::Element::new("rdf:RDF");
Expand Down Expand Up @@ -197,4 +197,14 @@ mod tests {

assert!(svg.contains("path d=\"M10,0 L20,0\""));
}

#[test]
fn test_svg_source_escale() {
let mut doc = Document::default();
doc.metadata_mut().source = Some("<hello>".to_owned());

let svg = doc.to_svg_string().unwrap();
assert!(svg.contains("&lt;hello&gt;"));
assert!(!svg.contains("<hello>"));
}
}

0 comments on commit 94f2e6a

Please sign in to comment.