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

pull/3753/head
Nutomic 11 months ago committed by GitHub
parent 9a5a13c734
commit 0e6fb08284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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> {

Loading…
Cancel
Save