fix(blame): fix incorrect rendering of angle brakets in git blame tooltip

This originally broke in f633b125b9, this
commit simply replaced `<` and `>` characters with their HTML encoded
equivalents. While this worked, it was not correct for the case where
`<` or `>` exist inside code blocks.

This also felt confusing that this was not happening where the markdown
was being parsed, but rather where where the blame message was retrieved
from git.

This commit fixes #22044, and **should not** cause a regression in
\#16220, by pushing any `InlineHtml` to the resulting string after
parsing the markdown.
This commit is contained in:
Cameron Clark 2024-12-15 21:11:10 +00:00
parent f64fcedabb
commit e66a653ea9
2 changed files with 5 additions and 1 deletions

View file

@ -32,7 +32,7 @@ pub fn get_messages(working_directory: &Path, shas: &[Oid]) -> Result<HashMap<Oi
String::from_utf8_lossy(&output.stdout)
.trim()
.split_terminator(MARKER)
.map(|str| str.trim().replace("<", "&lt;").replace(">", "&gt;")),
.map(|str| String::from(str.trim())),
)
.collect::<HashMap<Oid, String>>())
}

View file

@ -306,6 +306,10 @@ pub async fn parse_markdown_block(
Event::SoftBreak => text.push(' '),
Event::InlineHtml(inline_html) => {
text.push_str(&inline_html);
}
_ => {}
}
}