master
Aevann1 2021-11-04 17:20:10 +02:00
parent 159dd1387e
commit d863013e1b
6 changed files with 12 additions and 27 deletions

View File

@ -113,8 +113,6 @@ def send_unblock_notif(vid, user, text):
def send_admin(vid, text):
text = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', text)
text_html = Renderer().render(mistletoe.Document(text))
text_html = sanitize(text_html, True)

View File

@ -83,7 +83,7 @@ allowed_styles = ['color', 'font-weight', 'transform', '-webkit-transform']
def sanitize(sanitized, noimages=False):
sanitized = sanitized.replace("\ufeff", "").replace("m.youtube.com", "youtube.com")
sanitized = sanitized.replace("\ufeff", "").replace("m.youtube.com", "youtube.com").replace("𒐪","")
for i in re.finditer('https://i.imgur.com/(([^_]*?)\.(jpg|png|jpeg))', sanitized):
sanitized = sanitized.replace(i.group(1), i.group(2) + "_d." + i.group(3) + "?maxwidth=9999")

View File

@ -166,7 +166,6 @@ def api_comment(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 = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
body_md = body
options = []
@ -183,7 +182,6 @@ def api_comment(v):
url = request.host_url[:-1] + process_image(name)
body = request.values.get("body") + f"\n![]({url})"
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
body_md = CustomRenderer().render(mistletoe.Document(body))
body_html = sanitize(body_md)
else:
@ -398,7 +396,6 @@ def api_comment(v):
if "rama" in request.host and len(c.body) >= 1000 and "<" not in body and "</blockquote>" not in body_html:
body = random.choice(LONGPOST_REPLIES)
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
body_md = CustomRenderer().render(mistletoe.Document(body))
body_html2 = sanitize(body_md)

View File

@ -666,7 +666,6 @@ def submit_post(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 = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
options = []
for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body):

View File

@ -106,7 +106,6 @@ def settings_profile_post(v):
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', bio, re.MULTILINE):
if "wikipedia" not in i.group(1): bio = bio.replace(i.group(1), f'![]({i.group(1)})')
bio = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', bio)
if request.files.get('file'):
file = request.files['file']
@ -124,11 +123,6 @@ def settings_profile_post(v):
bio_html = sanitize(bio_html)
bans = filter_comment_html(bio_html)
if len(bio_html) > 10000:
return render_template("settings_profile.html",
v=v,
error="Your bio is too long")
if bans:
ban = bans[0]
reason = f"Remove the {ban.domain} link from your bio and try again."
@ -137,7 +131,10 @@ def settings_profile_post(v):
return {"error": reason}, 401
if len(bio_html) > 10000: abort(400)
if len(bio_html) > 10000:
return render_template("settings_profile.html",
v=v,
error="Your bio is too long")
v.bio = bio[:1500]
v.bio_html=bio_html
@ -149,20 +146,15 @@ def settings_profile_post(v):
if v.patron and request.values.get("sig"):
sig = request.values.get("sig")[:1500]
sig = request.values.get("sig")[:200]
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', sig, re.MULTILINE):
if "wikipedia" not in i.group(1): sig = sig.replace(i.group(1), f'![]({i.group(1)})')
sig = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', sig)
sig_html = CustomRenderer().render(mistletoe.Document(sig))
sig_html = sanitize(sig_html)
bans = filter_comment_html(sig_html)
if len(sig_html) > 10000:
return render_template("settings_profile.html",
v=v,
error="Your sig is too long")
if bans:
ban = bans[0]
@ -172,9 +164,12 @@ def settings_profile_post(v):
return {"error": reason}, 401
if len(sig_html) > 10000: abort(400)
if len(sig_html) > 1000:
return render_template("settings_profile.html",
v=v,
error="Your sig is too long")
v.sig = sig[:1500]
v.sig = sig[:200]
v.sig_html=sig_html
g.db.add(v)
g.db.commit()
@ -188,7 +183,6 @@ def settings_profile_post(v):
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', bio, re.MULTILINE):
if "wikipedia" not in i.group(1): bio = bio.replace(i.group(1), f'![]({i.group(1)})')
bio = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', bio)
if request.files.get('file'):
file = request.files['file']

View File

@ -238,8 +238,6 @@ def message2(v, username):
).first()
if existing: return redirect('/notifications?messages=true')
text = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', message)
text_html = Renderer().render(mistletoe.Document(text))
text_html = sanitize(text_html, True)
@ -291,7 +289,6 @@ def messagereply(v):
id = int(request.values.get("parent_id"))
parent = get_comment(id, v=v)
user = parent.author
message = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', message)
text_html = Renderer().render(mistletoe.Document(message))
text_html = sanitize(text_html, True)