From 67d8bd4324211d670fa43ad82aaf8600ed4084bd Mon Sep 17 00:00:00 2001 From: atrc445 Date: Sun, 19 Sep 2021 13:02:35 +0200 Subject: [PATCH] fix emoji tags --- files/helpers/sanitize.py | 6 +++--- files/routes/posts.py | 2 +- files/routes/reporting.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 1faff1953..d04454af2 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -220,7 +220,7 @@ def sanitize(sanitized, noimages=False): for i in re.finditer('

:([^ ]{1,30}?):

', sanitized): emoji = i.group(1).lower() if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'): - sanitized = sanitized.replace(f'

:{emoji}:

', f'

') + sanitized = sanitized.replace(f'

:{emoji}:

', f'

') try: if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1 @@ -231,7 +231,7 @@ def sanitize(sanitized, noimages=False): for i in re.finditer(':([^ ]{1,30}?):', sanitized): emoji = i.group(1).lower() if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'): - sanitized = sanitized.replace(f':{emoji}:', f'') + sanitized = sanitized.replace(f':{emoji}:', f'') try: if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1 @@ -264,6 +264,6 @@ def sanitize(sanitized, noimages=False): sanitized = sanitized.replace(rd, "https://old.reddit.com/") sanitized = re.sub(' (https:\/\/[^ <>]*)', r' \1', sanitized) - sanitized = re.sub('

(https:\/\/[^ <>]*)', r'

\1', sanitized) + sanitized = re.sub('

(https:\/\/[^ <>]*)', r'

\1

', sanitized) return sanitized diff --git a/files/routes/posts.py b/files/routes/posts.py index 1331e8a07..346a5e4dc 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -439,7 +439,7 @@ def filter_title(title): for i in re.finditer(':(.{1,30}?):', title): if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.webp'): - title = title.replace(f':{i.group(1)}:', f'') + title = title.replace(f':{i.group(1)}:', f'') return title diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 8b075216f..df00165b0 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -21,7 +21,7 @@ def api_flag_post(pid, v): for i in re.finditer(':(.{1,30}?):', reason): if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.webp'): - reason = reason.replace(f':{i.group(1)}:', f'') + reason = reason.replace(f':{i.group(1)}:', f'') flag = Flag(post_id=post.id, user_id=v.id, @@ -52,7 +52,7 @@ def api_flag_comment(cid, v): for i in re.finditer(':(.{1,30}?):', reason): if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.webp'): - reason = reason.replace(f':{i.group(1)}:', f'') + reason = reason.replace(f':{i.group(1)}:', f'') flag = CommentFlag(comment_id=comment.id, user_id=v.id,