dedup removing cuniform

master
Aevann 2023-05-20 14:09:40 +03:00
parent 0f6b36f40b
commit 7f565f5457
2 changed files with 15 additions and 7 deletions

View File

@ -273,19 +273,24 @@ def with_sigalrm_timeout(timeout: int):
return wrapped
return inner
def remove_cuniform(sanitized:Optional[str]) -> str:
if not sanitized: return ""
sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace('\u202e','').replace("\ufeff", "")
sanitized = sanitized.replace("𒐪","").replace("𒐫","").replace("","")
sanitized = sanitized.replace("\r\n", "\n")
sanitized = sanitized.strip()
return sanitized
def sanitize_raw_title(sanitized:Optional[str]) -> str:
if not sanitized: return ""
sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace("\ufeff", "").replace("\r","").replace("\n", "").replace("𒐫", "").replace('\u202e','')
sanitized = sanitized.strip()
sanitized = sanitized.replace("\r","").replace("\n", "")
sanitized = remove_cuniform(sanitized)
return sanitized[:POST_TITLE_LENGTH_LIMIT]
def sanitize_raw_body(sanitized:Optional[str], is_post:bool) -> str:
if not sanitized: return ""
sanitized = html_comment_regex.sub('', sanitized)
sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace("\ufeff", "").replace("\r\n", "\n").replace("𒐫", "").replace('\u202e','')
sanitized = sanitized.strip()
sanitized = remove_cuniform(sanitized)
return sanitized[:POST_BODY_LENGTH_LIMIT(g.v) if is_post else COMMENT_BODY_LENGTH_LIMIT]
@ -600,7 +605,9 @@ def allowed_attributes_emojis(tag, name, value):
@with_sigalrm_timeout(1)
def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False, strip=True):
title = title.replace('','').replace('','').replace("\ufeff", "").replace("𒐪","").replace("\n", "").replace("\r", "").replace("\t", "").replace('<','&lt;').replace('>','&gt;').replace("","")
title = title.replace("\n", "").replace("\r", "").replace("\t", "").replace('<','&lt;').replace('>','&gt;')
title = remove_cuniform(title)
emojis_used = set()

View File

@ -337,7 +337,8 @@ def award_thing(v, thing_type, id):
badge_grant(user=author, badge_id=58)
elif kind == "flairlock":
new_name = note[:100].replace("𒐪","").replace("","").strip()
new_name = note[:100]
new_name = remove_cuniform(new_name)
if not new_name and author.flairchanged:
author.flairchanged += 86400
else: