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

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 /// Sanitize HTML with default options. Additionally, dont allow bypassing markdown
/// links and images /// links and images
pub fn sanitize_html(data: &str) -> String { pub fn sanitize_html(data: &str) -> String {
ammonia::Builder::default() let sanitized = ammonia::Builder::default()
.rm_tags(&["a", "img"]) .rm_tags(&["a", "img"])
.clean(data) .clean(data)
.to_string() .to_string();
// restore markdown quotes
sanitized.replace("&gt;", ">")
} }
pub fn sanitize_html_opt(data: &Option<String>) -> Option<String> { pub fn sanitize_html_opt(data: &Option<String>) -> Option<String> {