diff --git a/src/api/comments/markdown.rs b/src/api/comments/markdown.rs index 5bb0da2..4e14f6c 100644 --- a/src/api/comments/markdown.rs +++ b/src/api/comments/markdown.rs @@ -5,15 +5,6 @@ #![allow(clippy::unused_unit, deprecated)] -/// 转义 HTML 特殊字符,用于无语言信息的代码块。 -#[cfg(feature = "server")] -fn html_escape(s: &str) -> String { - s.replace('&', "&") - .replace('<', "<") - .replace('>', ">") - .replace('"', """) -} - /// 清洗评论 HTML,移除危险标签与属性。 /// /// 实际委托给 `crate::api::sanitizer::clean_comment_html` 实现。 @@ -67,7 +58,7 @@ pub fn render_comment_markdown(md: &str) -> String { crate::highlight::server::highlight_code(&code_buffer, Some(lang)); format!("
{}
", highlighted) } else { - format!("
{}
", html_escape(&code_buffer)) + format!("
{}
", crate::utils::html::escape_html(&code_buffer)) }; events.push(Event::Html(html.into())); in_codeblock = false;