diff --git a/files/helpers/const.py b/files/helpers/const.py index a4aad8e91..f33567c5c 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -4,6 +4,28 @@ 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', +} + SLURS = { "retarded": "r-slurred", "retard": "r-slur", diff --git a/files/routes/comments.py b/files/routes/comments.py index 65482b3a3..f83868b87 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -195,6 +195,8 @@ def api_comment(v): body += f"\n\n![]({url})" + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.upper() 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 +596,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 +645,10 @@ 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) + + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.upper() + 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..4bf685516 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,8 @@ def edit_post(pid, v): elif len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 403 if title != p.title: + for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) + title = title.upper() 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 +259,11 @@ 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) + + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.upper() + + body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) bans = filter_comment_html(body_html) if bans: @@ -535,6 +540,8 @@ def submit_post(v): title = request.values.get("title", "").strip() url = request.values.get("url", "").strip() + for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) + title = title.upper() title_html = filter_title(title) body = request.values.get("body", "").strip() @@ -714,8 +721,10 @@ 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) + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.upper() + + 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 +996,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') diff --git a/files/templates/home.html b/files/templates/home.html index 29a4a8526..8f620ec78 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -3,6 +3,10 @@ {% block desktopBanner %} {% if v %} + {% if v.agendaposter %} + + {% endif %} +