dsfsfd
This commit is contained in:
parent
1d3e45a9b1
commit
17fb54a94b
3 changed files with 20 additions and 20 deletions
|
@ -1,7 +1,6 @@
|
||||||
import bleach
|
import bleach
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from bleach.linkifier import LinkifyFilter
|
from bleach.linkifier import LinkifyFilter
|
||||||
from urllib.parse import ParseResult, urlunparse, urlparse
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from .get import *
|
from .get import *
|
||||||
from os import path, environ
|
from os import path, environ
|
||||||
|
@ -88,7 +87,8 @@ _allowed_protocols = [
|
||||||
_allowed_styles =[
|
_allowed_styles =[
|
||||||
'color',
|
'color',
|
||||||
'font-weight',
|
'font-weight',
|
||||||
'transform'
|
'transform',
|
||||||
|
'-webkit-transform',
|
||||||
]
|
]
|
||||||
|
|
||||||
def sanitize(sanitized, noimages=False):
|
def sanitize(sanitized, noimages=False):
|
||||||
|
|
|
@ -157,7 +157,7 @@ def api_comment(v):
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
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'})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||||
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
|
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
# Run safety filter
|
# Run safety filter
|
||||||
|
@ -270,7 +270,7 @@ def api_comment(v):
|
||||||
|
|
||||||
body = request.values.get("body") + f"\n"
|
body = request.values.get("body") + f"\n"
|
||||||
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
|
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
if len(body_html) > 20000: abort(400)
|
if len(body_html) > 20000: abort(400)
|
||||||
|
@ -365,7 +365,7 @@ def api_comment(v):
|
||||||
|
|
||||||
body = AGENDAPOSTER_MSG.format(username=v.username)
|
body = AGENDAPOSTER_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ def api_comment(v):
|
||||||
|
|
||||||
body = random.choice(LONGPOST_REPLIES)
|
body = random.choice(LONGPOST_REPLIES)
|
||||||
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
|
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html2 = sanitize(body_md)
|
body_html2 = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ def api_comment(v):
|
||||||
if "rdrama" in request.host and random.random() < 0.001 and v.username != "Snappy" and v.username != "zozbot":
|
if "rdrama" in request.host and random.random() < 0.001 and v.username != "Snappy" and v.username != "zozbot":
|
||||||
|
|
||||||
body = "zoz"
|
body = "zoz"
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html2 = sanitize(body_md)
|
body_html2 = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ def api_comment(v):
|
||||||
|
|
||||||
|
|
||||||
body = "zle"
|
body = "zle"
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html2 = sanitize(body_md)
|
body_html2 = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ def api_comment(v):
|
||||||
|
|
||||||
|
|
||||||
body = "zozzle"
|
body = "zozzle"
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html2 = sanitize(body_md)
|
body_html2 = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ def edit_comment(cid, v):
|
||||||
body = request.values.get("body", "")[:10000]
|
body = request.values.get("body", "")[:10000]
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
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'})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
bans = filter_comment_html(body_html)
|
bans = filter_comment_html(body_html)
|
||||||
|
@ -689,7 +689,7 @@ def edit_comment(cid, v):
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = request.host_url[:-1] + process_image(name)
|
||||||
|
|
||||||
body += f"\n"
|
body += f"\n"
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
if len(body_html) > 20000: abort(400)
|
if len(body_html) > 20000: abort(400)
|
||||||
|
@ -706,7 +706,7 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
body = VAXX_MSG.format(username=v.username)
|
body = VAXX_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
@ -741,7 +741,7 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
body = AGENDAPOSTER_MSG.format(username=v.username)
|
body = AGENDAPOSTER_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ def edit_post(pid, v):
|
||||||
if body != p.body:
|
if body != p.body:
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
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'})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
# Run safety filter
|
# Run safety filter
|
||||||
|
@ -266,7 +266,7 @@ def edit_post(pid, v):
|
||||||
|
|
||||||
body = VAXX_MSG.format(username=v.username)
|
body = VAXX_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ def edit_post(pid, v):
|
||||||
|
|
||||||
body = AGENDAPOSTER_MSG.format(username=v.username)
|
body = AGENDAPOSTER_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
@ -737,7 +737,7 @@ def submit_post(v):
|
||||||
options.append(i.group(1))
|
options.append(i.group(1))
|
||||||
body = body.replace(i.group(0), "")
|
body = body.replace(i.group(0), "")
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
|
@ -905,7 +905,7 @@ def submit_post(v):
|
||||||
|
|
||||||
body = VAXX_MSG.format(username=v.username)
|
body = VAXX_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
@ -939,7 +939,7 @@ def submit_post(v):
|
||||||
|
|
||||||
body = AGENDAPOSTER_MSG.format(username=v.username)
|
body = AGENDAPOSTER_MSG.format(username=v.username)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
|
|
||||||
body_jannied_html = sanitize(body_md)
|
body_jannied_html = sanitize(body_md)
|
||||||
|
|
||||||
|
@ -982,7 +982,7 @@ def submit_post(v):
|
||||||
if new_post.url:
|
if new_post.url:
|
||||||
body += f"Snapshots:\n\n* [reveddit.com](https://reveddit.com/{new_post.url})\n* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={urllib.parse.quote(new_post.url)}&run=1) (click to archive)"
|
body += f"Snapshots:\n\n* [reveddit.com](https://reveddit.com/{new_post.url})\n* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={urllib.parse.quote(new_post.url)}&run=1) (click to archive)"
|
||||||
gevent.spawn(archiveorg, new_post.url)
|
gevent.spawn(archiveorg, new_post.url)
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body)).replace("<marquee>","<marquee><p>").replace("</marquee>","</marquee></p>")
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue