Restore markdown quotes after sanitize (#3708) (#3749)

This commit is contained in:
Nutomic 2023-07-28 14:23:46 +02:00 committed by GitHub
parent 9a5a13c734
commit 0e6fb08284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -798,10 +798,12 @@ pub fn generate_moderators_url(community_id: &DbUrl) -> Result<DbUrl, LemmyError
/// Sanitize HTML with default options. Additionally, dont allow bypassing markdown
/// links and images
pub fn sanitize_html(data: &str) -> String {
ammonia::Builder::default()
let sanitized = ammonia::Builder::default()
.rm_tags(&["a", "img"])
.clean(data)
.to_string()
.to_string();
// restore markdown quotes
sanitized.replace("&gt;", ">")
}
pub fn sanitize_html_opt(data: &Option<String>) -> Option<String> {