diff --git a/crates/svg/src/css.rs b/crates/svg/src/css.rs index 05ab3ce55..1b19da801 100644 --- a/crates/svg/src/css.rs +++ b/crates/svg/src/css.rs @@ -26,7 +26,28 @@ pub(crate) fn declarations<'a>(props: impl IntoIterator String { - format!("\"{}\"", s.replace('\\', "\\\\").replace('"', "\\\"")) + quoted(s, '"') +} + +/// `s` as a CSS string in `quote`s. A backslash and the quote are escaped, and so are line breaks +/// and other control characters (a newline would end the string and let the rest be rules) and +/// `<` and `>` (which could end a `"), r#""w\d \"\3c /style\3e ""#); + assert_eq!(css_string("wght"), "\"wght\""); + } }