fix: escape backslashes in debug locations for HTMLData serialization (#4116)

This commit is contained in:
liga authored and GitHub committed 2025-05-30 22:20:41 +02:00
1 parent 3565172255
commit 90adffd236
1 file changed
+9 -1
+9 -1
View File
@@ -346,7 +346,15 @@ impl HTMLData {
let body = list
.iter()
.map(|s| match s {
Some(s) => format!(r#""{s}""#),
Some(s) => {
// Escape backslashes, quotes, and newlines
let escaped = s
.replace(r#"\"#, r#"\\"#)
.replace("\n", r#"\n"#)
.replace(r#"""#, r#"\""#);
format!(r#""{escaped}""#)
}
None => r#""unknown""#.to_string(),
})
.collect::<Vec<_>>()