refactor: improve markdown sanitization by collapsing excessive newlines

This commit is contained in:
2026-05-01 20:55:19 +08:00
parent 70152c61b1
commit 477f090dfa
5 changed files with 5 additions and 562 deletions
+2 -1
View File
@@ -133,7 +133,8 @@ def _sanitize_converted_markdown(text: str) -> str:
value = (text or "").replace("\r\n", "\n").replace("\r", "\n")
value = IMAGE_MARKDOWN_RE.sub("", value)
value = IMAGE_HTML_RE.sub("", value)
return value
value = re.sub(r"\n{3,}", "\n\n", value)
return value.strip()
def get_client_ip(request: Request) -> str: