diff --git a/files/classes/user.py b/files/classes/user.py index be0988a66..49917ea5f 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -205,8 +205,9 @@ class User(Base): @property @lazy def ban_reason_link(self): - if self.ban_reason and (self.ban_reason.startswith("/post/") or self.ban_reason.startswith("/comment/")): - return self.ban_reason.split(" ", 1)[0] + if self.ban_reason: + if self.ban_reason.startswith("/post/"): return self.ban_reason.split(None, 1)[0] + if self.ban_reason.startswith("/comment/"): return self.ban_reason.split(None, 1)[0] + "?context=9#context" @property @lazy diff --git a/files/helpers/const.py b/files/helpers/const.py index a4aad8e91..83a5334ef 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -4,6 +4,37 @@ import re SITE = environ.get("DOMAIN", '').strip() SITE_NAME = environ.get("SITE_NAME", '').strip() +AJ_REPLACEMENTS = { + ':': '', + "'": '', + '-': '', + '.': '', + '!': '', + '"': '', + ';': '', + + 'their': '$#3$1', + 'there': 'their', + '$#3$1': 'there', + + "you're": '$#3$2', + 'your': "you're", + '$#3$2': 'your', + + "too": '$#3$3', + 'to': "too", + '$#3$3': 'to', + + '$#3$3': 'to', + '$#3$3': 'to', + '$#3$3': 'to', + + 'she': 'they', + 'her': 'they', + 'he': 'they', + 'him': 'they', +} + SLURS = { "retarded": "r-slurred", "retard": "r-slur", @@ -21,8 +52,8 @@ SLURS = { "kill yourself": "keep yourself safe", "kys": "keep yourself safe", "kyle": "Kylie", - "nig": "I LOVE BIG BLACK COCK IN MY BUSSY", - "nigger": "I LOVE BIG BLACK COCK IN MY BUSSY", + "nig": "🏀", + "nigger": "🏀", "rapist": "male feminist", "steve akins": "penny verity oaken", "trannie": "🚂🚃🚃", @@ -159,6 +190,9 @@ def censor_slurs(body: str, logged_user) -> str: if not logged_user or logged_user.slurreplacer: body = SLUR_REGEX.sub(sub_matcher, body) return body +def censor_slurs2(body: str) -> str: + return SLUR_REGEX.sub(sub_matcher, body) + BADGES = { 1: { 'name': 'Alpha User', diff --git a/files/routes/comments.py b/files/routes/comments.py index 65482b3a3..47853447e 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -195,6 +195,11 @@ def api_comment(v): body += f"\n\n![]({url})" + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.replace('I ', f'@{v.username}') + body = censor_slurs2(body).upper().replace(' ME ', f'@{v.username}') + body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403 @@ -594,7 +599,7 @@ def api_comment(v): g.db.commit() - if v.agendaposter and random.randint(1, 10) < 7: + if v.agendaposter and random.randint(1, 10) < 4: if request.host == 'rdrama.net': return redirect(random.choice(['https://secure.actblue.com/donate/ms_blm_homepage_2019','https://rdrama.net/post/19711/a-short-guide-on-how-to','https://secure.transequality.org/site/Donation2?df_id=1480'])) return redirect('https://secure.actblue.com/donate/ms_blm_homepage_2019') @@ -643,8 +648,13 @@ def edit_comment(cid, v): for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') - body_md = CustomRenderer().render(mistletoe.Document(body)) - body_html = sanitize(body_md) + + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.replace('I ', f'@{v.username}') + body = censor_slurs2(body).upper().replace(' ME ', f'@{v.username}') + + body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403 diff --git a/files/routes/posts.py b/files/routes/posts.py index 6e86b6e26..05d289592 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -104,7 +104,7 @@ def post_id(pid, anything=None, v=None): if v and request.path.startswith('/logged_out'): v = None - if v and v.agendaposter and random.randint(1, 10) < 3: + if v and v.agendaposter and random.randint(1, 20) == 1: if request.host == 'rdrama.net': return redirect(random.choice(['https://secure.actblue.com/donate/ms_blm_homepage_2019','https://rdrama.net/post/19711/a-short-guide-on-how-to','https://secure.transequality.org/site/Donation2?df_id=1480'])) return redirect('https://secure.actblue.com/donate/ms_blm_homepage_2019') @@ -249,6 +249,11 @@ def edit_post(pid, v): elif len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 403 if title != p.title: + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) + title = title.replace('I ', f'@{v.username}') + title = censor_slurs2(title).upper().replace(' ME ', f'@{v.username}') + title_html = filter_title(title) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 403 p.title = title @@ -257,8 +262,13 @@ def edit_post(pid, v): if body != p.body: for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') - body_md = CustomRenderer().render(mistletoe.Document(body)) - body_html = sanitize(body_md) + + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.replace('I ', f'@{v.username}') + body = censor_slurs2(body).upper().replace(' ME ', f'@{v.username}') + + body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) bans = filter_comment_html(body_html) if bans: @@ -535,6 +545,12 @@ def submit_post(v): title = request.values.get("title", "").strip() url = request.values.get("url", "").strip() + + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) + title = title.replace('I ', f'@{v.username}') + title = censor_slurs2(title).upper().replace(' ME ', f'@{v.username}') + title_html = filter_title(title) body = request.values.get("body", "").strip() @@ -714,8 +730,12 @@ def submit_post(v): options.append(i.group(1)) body = body.replace(i.group(0), "") - body_md = CustomRenderer().render(mistletoe.Document(body)) - body_html = sanitize(body_md) + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.replace('I ', f'@{v.username}') + body = censor_slurs2(body).upper().replace(' ME ', f'@{v.username}') + + body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 400 @@ -987,7 +1007,7 @@ def submit_post(v): g.db.commit() - if v.agendaposter and random.randint(1, 10) < 7: + if v.agendaposter and random.randint(1, 10) < 4: if request.host == 'rdrama.net': return redirect(random.choice(['https://secure.actblue.com/donate/ms_blm_homepage_2019','https://rdrama.net/post/19711/a-short-guide-on-how-to','https://secure.transequality.org/site/Donation2?df_id=1480'])) return redirect('https://secure.actblue.com/donate/ms_blm_homepage_2019')