Aevann 2023-03-24 13:43:15 +02:00
parent 09fce36d15
commit 3ee1851fa6
1 changed files with 4 additions and 2 deletions

View File

@ -265,14 +265,16 @@ def with_sigalrm_timeout(timeout: int):
def sanitize_raw_title(sanitized:Optional[str]) -> str: def sanitize_raw_title(sanitized:Optional[str]) -> str:
if not sanitized: return "" if not sanitized: return ""
sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace("\ufeff", "").replace("\r","").replace("\n", "").replace("𒐫", "") sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace("\ufeff", "").replace("\r","").replace("\n", "").replace("𒐫", "").replace('\u202e','')
sanitized = sanitized.strip() sanitized = sanitized.strip()
return sanitized[:POST_TITLE_LENGTH_LIMIT] return sanitized[:POST_TITLE_LENGTH_LIMIT]
def sanitize_raw_body(sanitized:Optional[str], is_post:bool) -> str: def sanitize_raw_body(sanitized:Optional[str], is_post:bool) -> str:
if not sanitized: return "" if not sanitized: return ""
sanitized = html_comment_regex.sub('', sanitized) sanitized = html_comment_regex.sub('', sanitized)
sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace("\ufeff", "").replace("\r\n", "\n").replace("𒐫", "")
print(sanitized, flush=True)
sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace("\ufeff", "").replace("\r\n", "\n").replace("𒐫", "").replace('\u202e','')
sanitized = sanitized.strip() sanitized = sanitized.strip()
return sanitized[:POST_BODY_LENGTH_LIMIT(g.v) if is_post else COMMENT_BODY_LENGTH_LIMIT] return sanitized[:POST_BODY_LENGTH_LIMIT(g.v) if is_post else COMMENT_BODY_LENGTH_LIMIT]