fix: escape backslashes in debug locations for HTMLData serialization (#4116)
This commit is contained in:
1 file changed
+9
-1
@@ -346,7 +346,15 @@ impl HTMLData {
|
|||||||
let body = list
|
let body = list
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| match s {
|
.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(),
|
None => r#""unknown""#.to_string(),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|||||||
Reference in new issue
Block a user