Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore markdown quotes after sanitize (#3708) #3749

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/api_common/src/utils.rs
Expand Up @@ -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> {
Expand Down