加固 UI HTML 注释转义

循环替换连续连字符,防止注释边界被提前闭合
This commit is contained in:
2026-09-01 15:28:35 +08:00
parent 7d88e58e35
commit 5e30ad8eac
@@ -9,9 +9,10 @@ pub(super) fn font_face_rule(
}
pub(super) fn html_comment(label: &str, value: serde_json::Value) -> Markup {
let text = serde_json::to_string_pretty(&value)
.unwrap_or_else(|_| "{}".to_string())
.replace("--", "- -");
let mut text = serde_json::to_string_pretty(&value).unwrap_or_else(|_| "{}".to_string());
while text.contains("--") {
text = text.replace("--", "- -");
}
PreEscaped(format!("<!-- {label}:\n{text}\n-->"))
}