mirror of
https://github.com/Mistake35/Cedar-Django.git
synced 2026-07-17 16:11:14 +10:00
I hate zalgo text
This commit is contained in:
@@ -19,6 +19,7 @@ from django.urls import reverse
|
|||||||
from django.db.models.signals import pre_delete
|
from django.db.models.signals import pre_delete
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
import re
|
import re
|
||||||
|
import unicodedata
|
||||||
import random
|
import random
|
||||||
|
|
||||||
feelings = ((0, 'normal'), (1, 'happy'), (2, 'wink'), (3, 'surprised'), (4, 'frustrated'), (5, 'confused'), (38, 'japan'), (39, 'lol i lied'), (69, 'adam is gay'), (70, 'I am a faggot!'), (71, 'Juice'), (72, "Commit Suicide"), (73, "Fresh!"))
|
feelings = ((0, 'normal'), (1, 'happy'), (2, 'wink'), (3, 'surprised'), (4, 'frustrated'), (5, 'confused'), (38, 'japan'), (39, 'lol i lied'), (69, 'adam is gay'), (70, 'I am a faggot!'), (71, 'Juice'), (72, "Commit Suicide"), (73, "Fresh!"))
|
||||||
@@ -769,6 +770,9 @@ class Community(models.Model):
|
|||||||
upload = None
|
upload = None
|
||||||
drawing = None
|
drawing = None
|
||||||
body = request.POST.get('body')
|
body = request.POST.get('body')
|
||||||
|
for c in body:
|
||||||
|
if unicodedata.combining(c):
|
||||||
|
return 11
|
||||||
if request.FILES.get('screen'):
|
if request.FILES.get('screen'):
|
||||||
upload = util.image_upload(request.FILES['screen'], True)
|
upload = util.image_upload(request.FILES['screen'], True)
|
||||||
if upload == 1:
|
if upload == 1:
|
||||||
@@ -956,6 +960,9 @@ class Post(models.Model):
|
|||||||
return 3
|
return 3
|
||||||
if not request.user.has_freedom() and (request.POST.get('url') or request.FILES.get('screen')):
|
if not request.user.has_freedom() and (request.POST.get('url') or request.FILES.get('screen')):
|
||||||
return 6
|
return 6
|
||||||
|
for c in request.POST['body']:
|
||||||
|
if unicodedata.combining(c):
|
||||||
|
return 11
|
||||||
if not request.user.is_active():
|
if not request.user.is_active():
|
||||||
return 6
|
return 6
|
||||||
if len(request.POST['body']) > 2200 or (len(request.POST['body']) < 1 and not request.POST.get('_post_type') == 'painting'):
|
if len(request.POST['body']) > 2200 or (len(request.POST['body']) < 1 and not request.POST.get('_post_type') == 'painting'):
|
||||||
|
|||||||
@@ -1065,8 +1065,8 @@ def community_create_action(request):
|
|||||||
get = request.POST.get
|
get = request.POST.get
|
||||||
user.c_tokens -= 1
|
user.c_tokens -= 1
|
||||||
user.save()
|
user.save()
|
||||||
Community.objects.create(name=get('community_name'), description=get('community_description'), type=3, platform=get('community_platform'), creator=user)
|
community = Community.objects.create(name=get('community_name'), description=get('community_description'), type=3, platform=get('community_platform'), creator=user)
|
||||||
return json_response('Done.')
|
return json_response('Community has been created', 'Done')
|
||||||
@login_required
|
@login_required
|
||||||
def post_create(request, community):
|
def post_create(request, community):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
@@ -1098,6 +1098,7 @@ def post_create(request, community):
|
|||||||
7: "Please don't spam.",
|
7: "Please don't spam.",
|
||||||
9: "You're very funny. Unfortunately your funniness blah blah blah fuck off.",
|
9: "You're very funny. Unfortunately your funniness blah blah blah fuck off.",
|
||||||
10: "No mr white, you can't make a post entirely consistant of spaces",
|
10: "No mr white, you can't make a post entirely consistant of spaces",
|
||||||
|
11: "Please don't post Zalgo text.",
|
||||||
}.get(new_post))
|
}.get(new_post))
|
||||||
# Render correctly whether we're posting to Activity Feed
|
# Render correctly whether we're posting to Activity Feed
|
||||||
if community.is_activity():
|
if community.is_activity():
|
||||||
@@ -1225,6 +1226,7 @@ def post_comments(request, post):
|
|||||||
2: "The image you've uploaded is invalid.",
|
2: "The image you've uploaded is invalid.",
|
||||||
3: "You're making comments too fast, wait a few seconds and try again.",
|
3: "You're making comments too fast, wait a few seconds and try again.",
|
||||||
6: "Not allowed.",
|
6: "Not allowed.",
|
||||||
|
11: "Please don't post Zalgo text.",
|
||||||
}.get(new_post))
|
}.get(new_post))
|
||||||
# Give the notification!
|
# Give the notification!
|
||||||
if post.is_mine(request.user):
|
if post.is_mine(request.user):
|
||||||
@@ -1754,6 +1756,8 @@ def user_tools_set(request, username):
|
|||||||
return json_response('Username Invalid')
|
return json_response('Username Invalid')
|
||||||
if not re.compile(r'^[A-Za-z0-9-._]{1,32}$').match(request.POST['username']) or not re.compile(r'[A-Za-z0-9]').match(request.POST['username']):
|
if not re.compile(r'^[A-Za-z0-9-._]{1,32}$').match(request.POST['username']) or not re.compile(r'[A-Za-z0-9]').match(request.POST['username']):
|
||||||
return json_response("The username either contains invalid characters or is too long (only letters + numbers, dashes, dots and underscores are allowed")
|
return json_response("The username either contains invalid characters or is too long (only letters + numbers, dashes, dots and underscores are allowed")
|
||||||
|
if User.objects.filter(username=request.POST['username']).exists() and not request.POST['username'] == user.username:
|
||||||
|
return json_response("Username is taken, please pick a new name.")
|
||||||
if request.POST.get('nickname') == "" or None:
|
if request.POST.get('nickname') == "" or None:
|
||||||
return json_response('Nickname Invalid')
|
return json_response('Nickname Invalid')
|
||||||
if request.POST.get('post_limit') == "" or None:
|
if request.POST.get('post_limit') == "" or None:
|
||||||
|
|||||||
Reference in New Issue
Block a user